EF迁移错误:无法加载类型'System.Data.Entity.Infrastructure.DbContextInfo' [英] EF Migrations error: could not load type 'System.Data.Entity.Infrastructure.DbContextInfo'

查看:1352
本文介绍了EF迁移错误:无法加载类型'System.Data.Entity.Infrastructure.DbContextInfo'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ContosoUniversity的例子。我刚刚使用Nuget下载并安装代码第一次迁移pakage。呃我exce ute exce ute ute ute>>>>>>> command>>。。。。。。。。。。是否有更多的安装nuget软件包?

 更新数据库:无法加载类型'System.Data.Entity。来自程序集EntityFramework,Version = 4.1.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089的Infrastructure.DbContextInfo'。 
在行:1 char:16
+ update-database<<<<<
+ CategoryInfo:NotSpecified:(:) [Update-Database],TypeLoadException
+ FullyQualifiedErrorId:System.TypeLoadException,System.Data.Entity.Migrations.Commands.MigrateCommand

编辑
现在我已经安装了 ADO.NET Entity Framework 4.1 - 更新1 现在它会抛出错误

 更新数据库:项目ContosoUniversity不包含或引用任何上下文。 
在行:1 char:16
+ update-database<<<<<
+ CategoryInfo:NotSpecified:(:) [Update-Database],InvalidOperationException
+ FullyQualifiedErrorId:System.InvalidOperationException,System.Data.Entity.Migrations.Commands.MigrateCommand

我已经在微软博客中尝试了这个场景,但没有改变。 ( http://blogs.msdn.com/b/adonet/archive/2011/07/27/code-first-migrations-august-2011-ctp-released.aspx

解决方案

尝试安装msi。



http://www.microsoft.com/download/en/details.aspx?id=26825



您收到的第二个错误听起来像在项目中识别上下文时遇到问题。确保你有一个继承自DbContext的类。



我还会检查你的项目是否引用了实体框架的正确版本 - 4.1更新1.根据项目类型,您应该能够在项目中的引用文件夹中找到有问题的引用。您可能需要点击显示所有文件按钮(解决方案资源管理器顶部工具栏左侧的第二个)。



一旦你有参考选择,您将在属性窗格中看到诸如DLL及其版本的路径等信息(F4如果尚不可见)。



编辑:根据下面的JTew,需要重新启动Visual Studio。


I am using ContosoUniversity example. I have just used Nuget to download and install code first migrations pakage. Whe I excecute update-database command it throws an error . Is there anything to do more than installing nuget package?

Update-Database : Could not load type 'System.Data.Entity.Infrastructure.DbContextInfo' from assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
At line:1 char:16
+ update-database <<<< 
    + CategoryInfo          : NotSpecified: (:) [Update-Database], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,System.Data.Entity.Migrations.Commands.MigrateCommand

Edit , Now I have installed ADO.NET Entity Framework 4.1 - Update 1 and now it throws an error

Update-Database : The project 'ContosoUniversity' does not contain or reference any contexts.
At line:1 char:16
+ update-database <<<< 
    + CategoryInfo          : NotSpecified: (:) [Update-Database], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException,System.Data.Entity.Migrations.Commands.MigrateCommand

I have tried the scenario in microsoft blog but nothing changed. ( http://blogs.msdn.com/b/adonet/archive/2011/07/27/code-first-migrations-august-2011-ctp-released.aspx )

解决方案

Try installing the msi.

http://www.microsoft.com/download/en/details.aspx?id=26825

The second error that you are getting sounds like it s having problems identifying a context within your project. Make sure that you have a class that inherits from DbContext.

I would also check that your project is referencing the correct version of the Entity Framework - 4.1 Update 1. Depending on the project type, you should be able to locate the reference in question within the References folder within your project. You may need to click on the 'Show All Files' button (second from the left in the toolbar at the top of the Solution Explorer).

Once you have the reference selected, you will see information such as the path of the DLL and its version in the Properties pane (F4 if it is not already visible).

Edit: According to JTew below, a restart of Visual Studio is required.

这篇关于EF迁移错误:无法加载类型'System.Data.Entity.Infrastructure.DbContextInfo'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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