Error loading type 'System.Data.Entity.Infrastructure.DbContextInfo' in EF Migrations

code-first ef-migrations entity-framework

Question

Contoso University is used as an example. I recently downloaded and installed the code first migrations package using Nuget. How I carry outupdate-database command, an error is thrown. What more has to be done than installing a 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 , I have now installedADO.NET Entity Framework 4.1 - Update 1 and now it makes a mistake

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

The Microsoft blog scenario was tested by me, but nothing changed. (http://blogs.msdn.com/b/adonet/archive/2011/07/27/code-first-migrations-august-2011-ctp-released.aspx)

1
3
1/19/2012 10:29:00 PM

Popular Answer

Install the msi, if you can.

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

It seems that the second issue you are receiving is having trouble locating a context inside your project. Please make sure your class inherits from DbContext.

I would also double-check that your project is using Entity Framework 4.1 Update 1 in the proper version. You ought should be able to find the elusive reference in your project's References folder, depending on the kind of project you're working on. It may be necessary to choose the 'Show All Files' option (second from the left in the toolbar at the top of the Solution Explorer).

Once the reference is chosen, the Properties pane will provide details such as the DLL's directory and version (F4 if it is not already visible).

Edit: According to JTew below, Visual Studio has to be restarted.

4
8/29/2011 7:06:00 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow