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 8408205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:34:12+00:00 2026-06-09T23:34:12+00:00

I am studying Code First EntityFramework together with ASP.Net MVC 3. At first my

  • 0

I am studying Code First EntityFramework together with ASP.Net MVC 3.
At first my trivial EFDbContext class was placed in the WebUI mvc project in a Concrete folder.

 public class EFDbContext : DbContext
 {
     public DbSet<Product> Products { get; set; }
 }

And it was consumed through

 public class EFProductRepository : IProductRepository
 {
    private EFDbContext context = new EFDbContext();

    public IQueryable<Product> Products
    {
        get
        {
            return context.Products;
        }
    }
 }

where

public interface IProductRepository
{
    IQueryable<Product> Products { get; }
}

So I added the following code to the root Web.config:

 <connectionStrings>
      <add name="WebUI.Concrete.EFDbContext" connectionString="Data Source=HORGH\SQLSERVER2008;Initial Catalog=SportStore;Integrated Security=True;Pooling=False"
providerName="System.Data.SqlClient"/>
 </connectionStrings>

and it worked.

Then I decided to take it into a separate Domain Class Library project. There I have an App.config file. So I decided to move my connection string there, and it became to be:

<connectionStrings>
      <add name="Domain.Concrete.EFDbContext" connectionString="Data Source=HORGH\SQLSERVER2008;Initial Catalog=SportStore;Integrated Security=True;Pooling=False"
providerName="System.Data.SqlClient"/>
 </connectionStrings>

But eventually EF stopped seeing it.

EFProductRepository and EFDbContext moved to the Domain project with their root folder Concrete. So the code calling the constructor is in EFProductRepository, i.e. in Domain project.

I tried to rename App.config to Web.Config; tried to return the connection string back to the Web.config of the WebUI project. It doesn’t work neither.

What am I doing wrong?

  • 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-06-09T23:34:13+00:00Added an answer on June 9, 2026 at 11:34 pm

    Class Library project and App.config file don’t mix.

    The application’s configuration file is always associated with an executable, or in the case of web.config, with a website.

    Your DLL project cannot (and should not) have its own config file*.

    Instead, configure the connection string along with your WebUI project. You can have multiple connection string entries.

    *There are actually ways to cause your DLL to in fact have its own config file. NLog, for one, does that. However, it is seldom a good idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Studying asp.net mvc 3 + EF code-first. I am new to both. My example
I have started to learn ASP.NET MVC, and at this time of studying I
I saw some code when studying the open source project: here . But I
I've been started studying PHP in my spare time, and the first code example
I have been studying .NET 4.0 Code Contracts and looking on stackoverflow as well
Hi I'm studying Python and I've started my first little project. The first thing
I'm in the middle in studying some code and I encountered this word "Append"
I am studying a MIPS code that uses procedure but I can not understand
I just saw this code while studying the wordpress source code (PHP), You can
I am going over/studying the facebook code that was leaked in 2007, I notice

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.