System.Data.Entity.Core.ProviderIncompatibleException
这是课程
public class Order { public virtual int OrderID { get; set; } }
上下文文件
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); }
和connctionstring的web.config文件部分
<connectionStrings> <add name="ShoppingCartDb" connectionString="Server=Localhost;Database=ShoppingCartEfdb;User Id=sa;Password=xxxxxxxxxx" providerName="System.Data.sqlClient" /> </connectionStrings>
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)
解决方法
原文地址:https://www.jb51.cc/mssql/77910.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。