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

code-first ef-migrations entity-framework


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=, 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. ( )

1/19/2012 10:29:00 PM

Popular Answer

Try installing the msi.

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.

8/29/2011 7:06:00 AM

Related Questions


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