Coder Perfect

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


To create an application, I’m using Entity Framework and ASP.NET MVC 4.

My solution is divided into two parts:

My issue is that when I try to use the DbContext ‘MyEntites,’ I receive the following error:

I believe the issue stems from the fact that the connection string is stored in the app.config of the class library rather than in the MVC project.

Is there anyone with any ideas?

Asked by jjc99

Solution #1

Try pasting the connections string into the MVC project’s.config file.

Answered by Jerry

Solution #2

This occurs because the class library (which contains the.edmx file) is not your starting / primary project.

The connection string must be copied to the main project config file.

If your startup / main project lacks a config file (as my Console Application did), just create one (Startup project – Add New Item -> Application Configuration File).

Here’s where you may find more pertinent information: MetadataException: The given metadata resource could not be loaded.

Answered by Oren

Solution #3

Make sure your project (with the DbContext) is set to startup mode.


In the app.config, add your connection string to the project that is set as startup (or web.config)


This is how you call the command:

‘Update-Database -Script -ProjectName’ ‘ -StartupProjectName ‘project name>’-StartupProjectName ‘ ‘ -ConnectionString ‘data source=.;initial catalog=;integrated security=True;MultipleActiveResultSets=True’ -ConnectionProviderName ‘System.Data.SqlClient’

Then try again

Answered by CMS

Solution #4

Simply send the connection string to EntityFramework and go about your business:

public partial class UtilityContext : DbContext
    static UtilityContext()

    public UtilityContext()
        : base("Data Source=SERVER;Initial Catalog=DATABASE;Persist Security Info=True;User ID=USERNAME;Password=PASSWORD;MultipleActiveResultSets=True")

    // DbSet, OnModelCreating, etc...

Answered by Serj Sagan

Solution #5

In the project that has been configured to “Set as StartUp Project,” copy the connection string to the app.config or web.config file, and if using entity framework in the data layer project, install entity framework nuget in the main project.

Answered by Ravi Anand

Post is based on