Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7078295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:31:48+00:00 2026-05-28T06:31:48+00:00

I am working in an application that uses EF,WCF and Asp.net. The application is

  • 0

I am working in an application that uses EF,WCF and Asp.net. The application is working fine with only one problem. The EF has an app.config file where the connection string is present

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="MyEntities" connectionString="metadata=res://*/DataAccessStrategy.Components.XYZ.csdl|res://*/DataAccessStrategy.Components.XYZ.ssdl|res://*/DataAccessStrategy.Components.XYZ.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=MyDataSource;Initial Catalog=MyDataBase;Persist Security Info=True;User ID=xxx;Password=xxx;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

Now the WCF service is the consumer to the EF service and henceforth in this config file I do have an entry of the same connection string as under

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="MyEntities" connectionString="metadata=res://*/DataAccessStrategy.Components.XYZ.csdl|res://*/DataAccessStrategy.Components.XYZ.ssdl|res://*/DataAccessStrategy.Components.XYZ.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=MyDataSource;Initial Catalog=MyDataBase;Persist Security Info=True;User ID=xxx;Password=xxx;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>
  <system.web>
    <compilation debug="true"/>
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
........
............

The asp.net application interacts with WCF as it’s config file is as under

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
<wsHttpBinding>
    .......................
    .........................

As can be figured out that, the connection string is present in 2 places.

Now it is not feasible. So I have removed the config file completely from the entity framework(so now it is present in the wcf application) and it worked fine.

But what I want is that I want to make it’s presence in the web.config file of Asp.net application and want to remove from the WCF app.config file. If I do so, I am getting an error message

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

Is it at all possible what I am looking for or I am asking something which is beyond scope?

Please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:31:48+00:00Added an answer on May 28, 2026 at 6:31 am

    If I understand your architecture correctly, the ASP.NET application doesn’t interact directly with EF or DB, therefore there is no need to have the connection string in its web.config file. You only need the connection string in WCF service config file which needs database access. This means the connection string is not in two places, the config files actually contain different information:

    • ASP.NET application config file contains WCF service endpoint information
    • WCF service config file contains the DB connection string

    Hypothetically you could remove the connection string from the WCF service config file and put it in the ASP.NET application config file but in this case you’d have to send it to WCF service with every method call. This is not a good approach and IMO doesn’t have any advantages over your current setup.

    You would need to add an aditional string parameter to all your WCF methods to receive the connection string from the ASP.NET application:

    public void ServiceMethod(string connectionString)
    {
        // use ObjectContext constructor with connectionString parameter
        using (var context = new MyEntities(connectionString))
        {
            // all your EF calls
        }
    }
    

    You could now move your connection string from the WCF config file to the ASP.NET config file. Before calling the web service method you would read the connection string from the config and pass it to it:

    var cs = ConfigurationManager.ConnectionStrings["MyEntities"].ConnectionString;
    wcfServiceClient.ServiceMethod(cs);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on an web application that uses ASP.NET 2.0 framework. I
I'm working on a Ruby web Application that uses the Net::FTP library. One part
I'm working on a web application that uses ASP.NET 3.5 and C#. Structurally, I
I'm looking for a working sample of an ASP.NET MVC web application that uses
I'm working on an application that uses asp.NET mvc3. I created a partial view,
I am working on a C# .NET application that uses LINQ to SQL for
I am working on a Silverlight application that uses WCF. I need to have
I am working on simple Workflow Foundation that uses a simple ASP.NET page as
I'm working on an application that uses WPF and WCF. As it stands now,
I'm working with an application that uses JBPM 3.1 and MySQL. The core problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.