小编Dav*_*ade的帖子

实体框架MigrateDatabaseToLatestVersion给出错误

我试图在我的网站上使用基于实体框架代码的迁移.我目前有一个包含多个项目的解决方案.我想要初始化数据库的Web API项目和另一个名为DataLayer项目的项目.我已在DataLayer项目中启用了迁移并创建了一个初始迁移,我希望它将用于创建数据库(如果它不存在).

这是我启用迁移时获得的配置

public sealed class Configuration : DbMigrationsConfiguration<Harris.ResidentPortal.DataLayer.ResidentPortalContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = false;
    }

    protected override void Seed(Harris.ResidentPortal.DataLayer.ResidentPortalContext context)
    {
        //  This method will be called after migrating to the latest version.

        //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
        //  to avoid creating duplicate seed data. E.g.
        //
        //    context.People.AddOrUpdate(
        //      p => p.FullName,
        //      new Person { FullName = "Andrew Peters" },
        //      new Person { FullName = "Brice Lambson" },
        //      new Person …
Run Code Online (Sandbox Code Playgroud)

entity-framework entity-framework-5

4
推荐指数
1
解决办法
6499
查看次数