Link to home
Create AccountLog in
Avatar of JosephEricDavis

asked on

Entity Framework utilized from a seperate project

I'm building an application that involves to pieces, a website and a WPF app that will be used as an admin tool to update content on the website.  The ASP.NET MVC 2 website is in one project and the WPF app is in another project, both in the same solution.  Because both apps will be accessing the same data, I created a third project to act as the data layer.  This project is just a C# class library.  I added an Entity Framework file to it based off of my already existing database.  I've done this before where the entity framework file is inside of the website and had no problems.  Now, when run try to utilize the entity framework from either project it always throws an error as soon as I instantiate the entity framework entities object.

The error I'm getting is:
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

The connection string for the entity framework object is stored in an App.Config file inside of the DataLayer project and was created when I created the Entity Framework object.

Any ideas why this might not be working?
Avatar of amit_g
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of JosephEricDavis


Is there not a more dynamic way to accomplish this?  Is it possible to only place the connection string in one place and have it be referenced by the other projects?
The config entries belong to the app not to the dlls. So it is best to take the config entries for each dll and put them in the app.config/web.config of consuming application. There are few ways to read the settings from the dll.config also but most are cumbersome and defeat the purpose.