方法& # 39;ExecuteAsync& # 39;没有实现.EF代码优先
本文关键字:代码 EF ExecuteAsync 方法 实现 | 更新日期: 2023-09-27 18:17:44
将我们的项目从4.0框架升级到4.6之后,我们开始收到从Visual Studio Package Manager Console运行的任何迁移命令的错误。
System.Reflection。TargetInvocationException:异常已被调用的目标抛出。——>系统。TypeInitializationException: System.Data.Entity.SqlServer的类型初始化器。SqlProviderServices抛出异常。——>系统。类型为System.Data.Entity.SqlServer的ExecuteAsync方法。DefaultSqlExecutionStrategy' from assembly '实体框架。SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'没有实现。
所有的EF dll都是为4.5框架。我尝试重新安装entityframework,删除引用,然后从packages->EntityFramework.6.1.3->lib->net45文件夹中再次选择它们,但没有任何帮助。
这是app的配置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<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="LocalDB" connectionString="data source=DAEDROTH-LAPTOP'DEV;initial catalog=LocalTest;persist security info=True;user id=Admin;password=1;multipleactiveresultsets=False;App=EntityFramework" providerName="System.Data.SqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
请帮。
我找到了解决方案。删除applicationhost即可。配置文件从your_project/。vs/config文件夹。