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 .
System.Data.Entity.Core.ProviderIncompatibleException
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());
modelBuilder.Properties<DateTime>()
.Configure(x => x.HasColumnType("datetime2"));
#endregion
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
base.OnModelCreating(modelBuilder);
}
And the web.config file section for connctionstring
<connectionStrings>
<add name="ShoppingCartDb"
connectionString="Server=Localhost;Database=ShoppingCartEfDb;User Id=sa;Password=xxxxxxxxxx"
providerName="System.Data.SqlClient" />
</connectionStrings>
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)
Entity Framework Extensions EF Core - SQL Server Provider. Microsoft SQL Server is a relational database management system (RDBMS) that supports a wide variety of transaction processing, business intelligence and analytic applications in corporate IT environments.
Here, we want to access MS SQL Server database, so we need to install Microsoft. EntityFrameworkCore. SqlServer NuGet package. To install the DB provider NuGet package, right click on the project in the Solution Explorer in Visual Studio and select Manage NuGet Packages..
Entity Framework Core is a modern object-database mapper for . NET. It supports LINQ queries, change tracking, updates, and schema migrations. EF Core works with many databases, including SQL Database (on-premises and Azure), SQLite, MySQL, PostgreSQL, and Azure Cosmos DB.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With