Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework 4.3 migrations error

I've just installed EF 4.3-beta1 for the migrations goodness, and I can't get it working. The error I get:

PM> Update-Database -Verbose
Using NuGet project 'Project.Domain'.
Using StartUp project 'ProjectWebSite'.
System.InvalidOperationException: No migrations configuration type was found in the assembly 'Project.Domain'.
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
No migrations configuration type was found in the assembly 'Project.Domain'.

I've added a new column to 2 EF classes:

public class MasterInstance
{
    public int MasterInstanceId { get; set; }
    [Required] public string HostName { get; set; }
    [Required] public string Name { get; set; } /* <-- THIS IS NEW */
    [Required] public string ConnectionString { get; set; }
    public virtual ICollection<MasterInstanceLocation> MasterInstanceLocations { get; set; }
}

And my DbContext looks like this:

public class ProjectDontext: DbContext, IProjectContext
{
    public IDbSet<Installer> Installers { get; set; }
    public IDbSet<MasterInstance> MasterInstances { get; set; }
    public IDbSet<MasterInstanceLocation> MasterInstanceLocations { get; set; }
}

Any ideas? My EF classes & context live in a separate assembly (Project.Domain). I've tried running the update-database in the context of both the main website and the domain project, and I get the same error either way.

-- EDIT --

Solution found. It turns out, that you need to enable migrations for your project. You can do this by running Enable-Migrations in the NuGet console (make sure you have the right project selected - for me this was the project.domain project).

This walkthrough provides more information

like image 818
Matt Roberts Avatar asked Jan 30 '12 11:01

Matt Roberts


2 Answers

Solution found. It turns out, that you need to enable migrations for your project. You can do this by running Enable-Migrations in the NuGet console (make sure you have the right project selected - for me this was the project.domain project).

This walkthrough provides more information

like image 113
Matt Roberts Avatar answered Sep 24 '22 22:09

Matt Roberts


Sometimes, even if you have enabled migration, this problem can occur. It means that configuration file has been deleted. In this case, you can run

Enable-Migrations -Force 

in the Package Manager Console. -Force parameter is to override migration configuration file.

like image 20
Anjani Avatar answered Sep 24 '22 22:09

Anjani