Entity Framework 6 with SQL Server 2012 gives System.Data.Entity.Core.ProviderIncompatibleException

entity-framework-6 sql-server-2012


I have Visual Studio 2012 and I'm using the Entity Framework stack with EF 6. I did all correct but while adding migration I am getting the error .


Here are the classes

public class Order
    public virtual int OrderID { get; set; }

The context file

public ShoppingCartContext() : base("ShoppingCartDb")
        Database.SetInitializer<ShoppingCartContext>(new DropCreateDatabaseAlways<ShoppingCartContext>());

protected override void OnModelCreating(DbModelBuilder modelBuilder)
        #region Entity Framework 6 RC-1
        modelBuilder.Properties().Where(x => x.Name == x.DeclaringType.ToString() + "ID")
                .Configure(x => x.IsKey());

                .Configure(x => x.HasColumnType("datetime2"));


And the web.config file section for connctionstring

   <add name="ShoppingCartDb" 
        connectionString="Server=Localhost;Database=ShoppingCartEfDb;User Id=sa;Password=xxxxxxxxxx" 
        providerName="System.Data.SqlClient" />

I am getting the error whenever I am trying to add migration as :

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)

9/3/2013 4:58:34 AM

Accepted Answer

Try this. Make sure that the project that your ShoppingCartContext is in, is the start up project or when executing the add-migration command include the parameter -startupprojectname ex. add-migration -startupprojectname yourprojectname

10/26/2013 12:49:36 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow