实体框架4.3迁移错误 [英] Entity Framework 4.3 migrations error

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

问题描述

出于迁移方面的考虑,我刚刚安装了EF 4.3-beta1,但我无法使其正常运行.我得到的错误:

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'.

我在2个EF类中添加了新列:

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; }
}

我的DbContext看起来像这样:

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; }
}

有什么想法吗?我的EF课程和上下文位于单独的程序集中(Project.Domain).我曾尝试在主网站和域项目的上下文中运行更新数据库,但无论哪种方式,我都会遇到相同的错误.

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.

-编辑-

找到解决方案.事实证明,您需要为项目启用迁移.您可以通过在NuGet控制台中运行 Enable-Migrations 来做到这一点(确保您选择了正确的项目-对我来说这是project.domain项目).

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).

本演练提供了更多信息

推荐答案

找到解决方案.事实证明,您需要为项目启用迁移.您可以通过在NuGet控制台中运行 Enable-Migrations 来做到这一点(确保您选择了正确的项目-对我来说这是project.domain项目).

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).

此演练提供更多信息

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

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