No connection string named 'MyEntities' could be found in the application config file

jjc99 picture jjc99 · Sep 27, 2012 · Viewed 231.2k times · Source

I am using entity framework and ASP.NET MVC 4 to build an application

My solution is split into two projects;

  • A class library that includes my data model (.edmx) file and a few custom interfaces
  • The 'container' MVC project that references the class library above

My problem is that when I attempt to use the 'MyEntites' DbContext I get the the following error:

No connection string named 'MyEntities' could be found in the application config file.

I guess the problem has something to do with the fact that connection string lies within the app.config of the class library rather than the MVC project.

Does anyone have any suggestions?

Answer

Jerry picture Jerry · Sep 27, 2012

Try copying the connections string to the .config file in the MVC project.