实体框架代码首次迁移 [英] Entity Framework Code First Migrations

查看:427
本文介绍了实体框架代码首次迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行以下命令

pm> Update-Database

获取以下错误


System.Reflection.TargetInvocationException:异常被调用的目标抛出。 --->
System.TypeInitializationException:
'System.Data.Entity.SqlServer.SqlProviderServices'的类型初始化器抛出异常。
---> System.TypeLoadException:从
assembly'EntityFramework.SqlServer,Version = 6.0.0.0,Culture = neutral,'类型'System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy'中的方法'ExecuteAsync'
PublicKeyToken = b77a5c561934e089'没有实现。

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'System.Data.Entity.SqlServer.SqlProviderServices' threw an exception. ---> System.TypeLoadException: Method 'ExecuteAsync' in type 'System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy' from assembly 'EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' does not have an implementation.


推荐答案

您的EF版本项目版本不相等。
您的实体框架是.net 4的版本6,但您的项目使用.net 4.5
.net版本4.5的项目必须使用EF for .Net4.5

Your EF version and Project Version is not Equal. your Entity Framework is ver 6 of .Net 4 but your project use .net 4.5 Project by .net version 4.5 must use EF for .Net4.5

这篇关于实体框架代码首次迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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