Error when edmx file is in a separate project

2019-05-18 13:30发布

问题:

I have problem that says

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

My edmx file is in separate project, but that project has connection string in its app.config

What could cause the problem?

回答1:

Make sure the app.config is in the project which is set to be the startup project.

IF I understand correctly (I hope I do!):

You have two projects:

ApplicationServices (Startup Project)

  • Web.config

EntityContainer

  • MyEdmx.edmx

  • App.config

When the project starts up, it reads from the web.config file.

You need to make sure the connection string is in the web.config file. I usually remove the app.config from the other projects if I do not plan on using them.

Also double check ApplicationServices project references EntityContainer.