EF添加迁移生成空迁移 [英] EF add-migration generates empty migration

查看:206
本文介绍了EF添加迁移生成空迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的模型中添加了一个新表:

  public DbSet< ReturnedTransactions> ReturnedTransactions {get;组; } 

我希望我的迁移为我生成该表,所以我做了:

  PM> Add-migration returnedTransactions 

它生成



<$ public


覆盖void Down()
{
}
}

我强制这个东西为我生成正确的代码?

解决方案

我看到这种情况发生在我不添加我的DBSet实体我的DbContext类与迁移配置文件相关联。



尽管可能不是这样,因为我们可以看到Asker包括以下行:

  public DbSet< ReturnedTransactions> ReturnedTransactions {get;组; } 

尽管如此,这是返回空迁移类时应检查的内容。 >

I added into my model a new table:

public DbSet<ReturnedTransactions> ReturnedTransactions { get; set; }

And i want my migrations to generate that table for me, so i did:

PM> Add-migration returnedTransactions

And it generated

public partial class returnedTransactions : DbMigration
{
    public override void Up()
    {
    }

    public override void Down()
    {
    }
}

How do i force this thing to generate proper code for me?

解决方案

I see this happen when I do not add my DBSet Entity to my DbContext class that is associated with the Migration Configuration file.

Although, it may not be the case here as we can see that the Asker included the line:

public DbSet<ReturnedTransactions> ReturnedTransactions { get; set; }

Still, this is something one should check when they are returned an empty migration class.

这篇关于EF添加迁移生成空迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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