I am trying out Visual Studio 2013 Entity Framework 6 Code First to create a new database.
So I coded the model (i.e. entity classes) and the context (i.e. DbContext).
When I tried “Enable-Migrations” in package manager console, I got the following error:
Checking if the context targets an existing database…
System.Data.Entity.Core.ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct. —> System.Data.Entity.Core.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. —> System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)
1. Find out the actual connection string being used by writing out the connecting string in your Context class’s constructor. Of course you will need to run/debug the code in order to see the connections string in the debug output window.
2. Add the connection string to the Context class
With the default code first approach, you won’t find a connection string in web.config.
Things are done by convention and there is no need specify a connection string. However, since it is not working, I am using the work around.
I suppose specifying the connection string explicitly in the web.config should also work.