在MVC 5 System.Data.Entity.Core.ProviderIncompatible异常 [英] System.Data.Entity.Core.ProviderIncompatible Exception in MVC 5

查看:3700
本文介绍了在MVC 5 System.Data.Entity.Core.ProviderIncompatible异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的mvc5 ASP.NET Web应用程序和我做了一个模型类与控制器。我的应用程序正在运行,但是当我要访问我的moviescontroller url中像本地主机:1234 /电影它产生在我MoviesController.cs文件例外

这是我使用的连接字符串

 <&是connectionStrings GT;
    <添加名称=DefaultConnection的connectionString =数据源=(的LocalDB)\\ V11.0; AttachDbFilename = | DataDirectory目录| \\ ASPNET-MvcMovie-20130819083100.mdf;初始目录= ASPNET-MvcMovie-20130819083100;集成安全性=真
      的providerName =System.Data.SqlClient的/>
    <添加名称=MovieDBContext的connectionString =数据源=(的LocalDB)\\ V11.0; AttachDbFilename = | DataDirectory目录| \\ Movies.mdf;用户ID = SA;密码=密码@ 123;的providerName =System.Data.SqlClient的/>
< /&是connectionStrings GT;

该功能可以产生这种例外是

 公众的ActionResult指数()
{
    返回查看(db.Movies.ToList());
}

编辑异常详细信息

类型'System.Data.Entity.Core.ProviderIncompatibleException的异常出现在EntityFramework.dll但在用户code没有处理

附加信息:在获取从数据库提供信息时出错。这可以通过实体框架使用了不正确的连接字符串引起的。检查内部异常的详细信息,并确保连接字符串是正确的。

内部异常详细信息:

  System.Data.Entity.Core.ProviderIncompatibleException是由用户code未处理
  的HResult = -2146233087
  消息=同时获得由数据库提供信息时出错。这可以通过实体框架使用了不正确的连接字符串引起的。检查内部异常的详细信息,并确保连接字符串是正确的。
  来源=的EntityFramework
  堆栈跟踪:
       在System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices,连接的DbConnection)
       在System.Data.Entity.Infrastructure.DefaultManifestTokenService.GetProviderManifestToken(连接的DbConnection)
       在System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(连接的DbConnection,DbProviderManifest&安培; providerManifest)
       在System.Data.Entity.DbModelBuilder.Build(的DbConnection providerConnection)
       在System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
       在System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput输入)
       在System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
       在System.Data.Entity.Internal.InternalContext.Initialize()
       在System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(类型的EntityType)
       在System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
       在System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator()
       在System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
       在System.Collections.Generic.List`1..ctor(IEnumerable`1集合)
       在System.Linq.Enumerable.ToList [TSource](IEnumerable`1源)
       在MvcMovie.Controllers.MoviesController.Index()在d:\\ Nimit乔希\\网站\\ MvcMovie \\ MvcMovie \\ \\控制器MoviesController.cs:行20
       在lambda_method(封闭,ControllerBase,对象[])
       在System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase控制器,对象[]参数)
       在System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary`2参数)
       在System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext,ActionDescriptor actionDescriptor,IDictionary`2参数)
       在System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
       在System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__36(IAsyncResult asyncResult,ActionInvocation innerInvokeState)
       在System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult的asyncResult)
       在System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
       在System.Web.Mvc.Async.AsyncResultWrapper.End [TResult](IAsyncResult的asyncResult,对象标记)
       在System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult的asyncResult)
       在System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3c()
       在System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e()
  的InnerException:System.Data.Entity.Core.ProviderIncompatibleException
       的HResult = -2146233087
       消息=提供者未返回ProviderManifestToken字符串。
       来源=的EntityFramework
       堆栈跟踪:
            在System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(连接的DbConnection)
            在System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices,连接的DbConnection)
       的InnerException信息:System.Data.SqlClient.SqlException
            的HResult = -2146232060
            消息=建立到SQL Server的连接时发生网络相关的或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:50 - 发生本地数据库运行时错误无法创建一个自动实例请参阅Windows应用程序事件日志错误的详细信息。

            来源= .net SqlClient数据提供
            错误code = -2146232060
            CLASS = 20
            行号= 0
            数= -1983577832
            服务器=
            状态= 0
            堆栈跟踪:
                 在System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔breakConnection,Action`1 wrapCloseInAction)
                 在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,布尔callerHasConnectionLock,布尔asyncClose)
                 在System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo,SqlInternalConnectionTds connHandler,布尔ignoreSniOpenTimeout,Int64的timerExpire,布尔值加密,布尔trustServerCert,布尔integratedSecurity布尔withFailover)
                 在System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo,字符串NEWPASSWORD,SecureString的newSecurePassword,布尔ignoreSniOpenTimeout,TimeoutTimer超时,布尔withFailover)
                 在System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo,字符串NEWPASSWORD,SecureString的newSecurePassword,布尔redirectedUserInstance,SqlConnectionString connectionOptions,SqlCredential凭证,TimeoutTimer超时)
                 在System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer超时,SqlConnectionString connectionOptions,SqlCredential凭证,字符串NEWPASSWORD,SecureString的newSecurePassword,布尔redirectedUserInstance)
                 在System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity身份,SqlConnectionString connectionOptions,SqlCredential凭证,对象providerInfo,字符串NEWPASSWORD,SecureString的newSecurePassword,布尔redirectedUserInstance,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData)
                 在System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项,DbConnectionPoolKey poolKey,对象poolGroupProviderInfo,池类DBConnectionPool,的DbConnection owningConnection,DbConnectionOptions USEROPTIONS)
                 在System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(池类DBConnectionPool,的DbConnection owningObject,DbConnectionOptions选项,DbConnectionPoolKey poolKey,DbConnectionOptions USEROPTIONS)
                 在System.Data.ProviderBase.DbConnectionPool.CreateObject(的DbConnection owningObject,DbConnectionOptions USEROPTIONS,DbConnectionInternal oldConnection)
                 在System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(的DbConnection owningObject,DbConnectionOptions USEROPTIONS,DbConnectionInternal oldConnection)
                 在System.Data.ProviderBase.DbConnectionPool.TryGetConnection(的DbConnection owningObject,UInt32的waitForMultipleObjectsTimeout,布尔allowCreate,布尔onlyOneCheckConnection,DbConnectionOptions USEROPTIONS,DbConnectionInternal&安培;连接)
                 在System.Data.ProviderBase.DbConnectionPool.TryGetConnection(的DbConnection owningObject,TaskCompletionSource`1重试,DbConnectionOptions USEROPTIONS,DbConnectionInternal&安培;连接)
                 在System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(的DbConnection owningConnection,TaskCompletionSource`1重试,DbConnectionOptions USEROPTIONS,DbConnectionInternal oldConnection,DbConnectionInternal&安培;连接)
                 在System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(的DbConnection outerConnection,DbConnectionFactory connectionFactory的,TaskCompletionSource`1重试,DbConnectionOptions USEROPTIONS)
                 在System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(的DbConnection outerConnection,DbConnectionFactory connectionFactory的,TaskCompletionSource`1重试,DbConnectionOptions USEROPTIONS)
                 在System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1重试)
                 在System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1重试)
                 在System.Data.SqlClient.SqlConnection.Open()
                 在System.Data.Entity.SqlServer.SqlProviderServices.<>c__DisplayClass2c.<UsingConnection>b__2a()
                 在System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
                 在System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute [TResult](Func`1 FUNC)
                 在System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(动作动作)
                 在System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(SqlConnection的的DbConnection,Action`1行为)
                 在System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(SqlConnection的的DbConnection,Action`1行为)
                 在System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifestToken(连接的DbConnection)
                 在System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(连接的DbConnection)
            的InnerException:

我的DbContext类是:

 公共类MovieDBContext:的DbContext
{
    公共DbSet&LT;电影及GT;电影{搞定;组; }
 }

我的整个配置文件是:

 &LT;?XML版本=1.0编码=UTF-8&GT?;
&LT;! -
  有关如何配置ASP.NET应用程序的更多信息,请访问:
  http://go.microsoft.com/fwlink/?LinkId=301880
   - &GT;
&LT;结构&gt;
  &LT; configSections&GT;
    &LT;! - 有关Entity Framework的配置的详细信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468 - &GT;
    &lt;节名称=的EntityFrameworkTYPE =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,的EntityFramework,版本6.0.0.0 =文化=中性公钥= b77a5c561934e089requirePermission =FALSE/&GT;
  &LT; / configSections&GT;
  &LT;&是connectionStrings GT;
    &LT;添加名称=DefaultConnection的connectionString =数据源=(的LocalDB)\\ V11.0; AttachDbFilename = | DataDirectory目录| \\ ASPNET-MvcMovie-20130819083100.mdf;初始目录= ASPNET-MvcMovie-20130819083100;集成安全性=真
      的providerName =System.Data.SqlClient的/&GT;
    &LT;添加名称=MovieDBContext的connectionString =数据源=(的LocalDB)\\ V11.0;初始目录= TempMovies; AttachDbFilename = | DataDirectory目录| \\ TempMovies.mdf;集成安全性=真的providerName =System.Data.SqlClient的/&GT;
  &LT; /&是connectionStrings GT;
  &LT;&的appSettings GT;
    &LT;添加键=网页:版本值=3.0.0.0/&GT;
    &LT;添加键=网页:启用VALUE =FALSE/&GT;
    &LT;添加关键=preserveLoginUrlVALUE =真/&GT;
    &LT;添加键=ClientValidationEnabledVALUE =真/&GT;
    &LT;添加键=UnobtrusiveJavaScriptEnabledVALUE =真/&GT;
  &LT; /的appSettings&GT;
  &LT;&的System.Web GT;
    &LT;编译调试=真targetFramework =4.5.1/&GT;
    &LT;的httpRuntime targetFramework =4.5.1/&GT;
    &LT;网页和GT;
      &LT;&命名空间GT;
        &LT;添加命名空间=System.Web.Helpers/&GT;
        &LT;添加命名空间=System.Web.Mvc/&GT;
        &LT;添加命名空间=System.Web.Mvc.Ajax/&GT;
        &LT;添加命名空间=System.Web.Mvc.Html/&GT;
        &LT;添加命名空间=System.Web.Optimization/&GT;
        &LT;添加命名空间=System.Web.Routing/&GT;
        &LT;添加命名空间=System.Web.WebPages/&GT;
        &LT;添加命名空间=MvcMovie/&GT;
      &LT; /命名空间&GT;
    &LT; /页&GT;
  &LT; /system.web>
  &LT; system.webServer&GT;
    &LT;验证validateIntegratedModeConfiguration =FALSE/&GT;
  &LT; /system.webServer>
  &LT;&运行GT;
    &LT; assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1&GT;
      &LT; dependentAssembly&GT;
        &LT; assemblyIdentity名称=System.Web.Helpers公钥=31bf3856ad364e35/&GT;
        &LT; bindingRedirect oldVersion =1.0.0.0-3.0.0.0NEWVERSION =3.0.0.0/&GT;
      &LT; / dependentAssembly&GT;
      &LT; dependentAssembly&GT;
        &LT; assemblyIdentity名称=System.Web.Mvc公钥=31bf3856ad364e35/&GT;
        &LT; bindingRedirect oldVersion =1.0.0.0-5.0.0.0NEWVERSION =5.0.0.0/&GT;
      &LT; / dependentAssembly&GT;
      &LT; dependentAssembly&GT;
        &LT; assemblyIdentity名称=System.Web.WebPages公钥=31bf3856ad364e35/&GT;
        &LT; bindingRedirect oldVersion =1.0.0.0-3.0.0.0NEWVERSION =3.0.0.0/&GT;
      &LT; / dependentAssembly&GT;
      &LT; dependentAssembly&GT;
        &LT; assemblyIdentity名称=WebGrease公钥=31bf3856ad364e35/&GT;
        &LT; bindingRedirect oldVersion =1.0.0.0-1.3.0.0NEWVERSION =1.3.0.0/&GT;
      &LT; / dependentAssembly&GT;
    &LT; / assemblyBinding&GT;
  &LT; /运行&GT;
  &LT;&的EntityFramework GT;
    &LT; defaultConnectionFactory TYPE =System.Data.Entity.Infrastructure.SqlConnectionFactory,的EntityFramework/&GT;
    &LT;供应商&GT;
      &LT;供应商invariantName =System.Data.SqlClient的TYPE =System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer/&GT;
    &LT; /供应商&GT;
  &LT; /&的EntityFramework GT;
&LT; /结构&gt;


解决方案

我的LocalDB已被删除。我重新它和我的项目现在运行成功。谢谢大家支持我。

I am creating an ASP.NET Web Application in mvc5 and i made a model class with a controller. My application is running but when i want to access my moviescontroller in url like localhost:1234/Movies it generates an exception in my MoviesController.cs file

The connection string that I'm using is

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MvcMovie-20130819083100.mdf;Initial Catalog=aspnet-MvcMovie-20130819083100;Integrated Security=True"
      providerName="System.Data.SqlClient" />
    <add name="MovieDBContext" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;User ID=sa; Password=password@123;" providerName="System.Data.SqlClient"/>
</connectionStrings>

Function that generating this exception is

public ActionResult Index()
{
    return View(db.Movies.ToList());
}

Edit Exception Details

An exception of type 'System.Data.Entity.Core.ProviderIncompatibleException' occurred in EntityFramework.dll but was not handled in user code

Additional information: 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.

Inner Exception Details:

    System.Data.Entity.Core.ProviderIncompatibleException was unhandled by user code
  HResult=-2146233087
  Message=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.
  Source=EntityFramework
  StackTrace:
       at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
       at System.Data.Entity.Infrastructure.DefaultManifestTokenService.GetProviderManifestToken(DbConnection connection)
       at System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
       at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
       at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
       at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
       at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
       at System.Data.Entity.Internal.InternalContext.Initialize()
       at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
       at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
       at System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator()
       at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at MvcMovie.Controllers.MoviesController.Index() in d:\Nimit Joshi\Websites\MvcMovie\MvcMovie\Controllers\MoviesController.cs:line 20
       at lambda_method(Closure , ControllerBase , Object[] )
       at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
       at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__36(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
       at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3c()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e()
  InnerException: System.Data.Entity.Core.ProviderIncompatibleException
       HResult=-2146233087
       Message=The provider did not return a ProviderManifestToken string.
       Source=EntityFramework
       StackTrace:
            at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
            at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
       InnerException: System.Data.SqlClient.SqlException
            HResult=-2146232060
            Message=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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
)
            Source=.Net SqlClient Data Provider
            ErrorCode=-2146232060
            Class=20
            LineNumber=0
            Number=-1983577832
            Server=""
            State=0
            StackTrace:
                 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
                 at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
                 at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
                 at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
                 at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
                 at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
                 at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
                 at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
                 at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
                 at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
                 at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
                 at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
                 at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
                 at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
                 at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
                 at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
                 at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
                 at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
                 at System.Data.SqlClient.SqlConnection.Open()
                 at System.Data.Entity.SqlServer.SqlProviderServices.<>c__DisplayClass2c.<UsingConnection>b__2a()
                 at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
                 at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 func)
                 at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action action)
                 at System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act)
                 at System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act)
                 at System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection)
                 at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
            InnerException: 

My DbContext class is:

public class MovieDBContext : DbContext
{
    public  DbSet<Movie> Movies { get; set; }
 }

My Whole Configuration File is:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MvcMovie-20130819083100.mdf;Initial Catalog=aspnet-MvcMovie-20130819083100;Integrated Security=True"
      providerName="System.Data.SqlClient" />
    <add name="MovieDBContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=TempMovies;AttachDbFilename=|DataDirectory|\TempMovies.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
        <add namespace="MvcMovie" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

解决方案

My LocalDB was deleted. I recreate it and my project now is running successfully. Thank you all to support me.

这篇关于在MVC 5 System.Data.Entity.Core.ProviderIncompatible异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆