首页 > 解决方案 > 为什么实体框架中的迁移文件在 up() 和 down() 方法中没有代码?

问题描述

我正在尝试使用名称创建一个新的迁移InitialModel。但是,当我打开迁移文件时,我只能看到空up()down()方法。createTable()方法中应该有up()方法。我已经删除了迁移,更新了数据库并开始了一个新项目,但是,这些都没有奏效。有人可以告诉我如何获取迁移文件以显示createTable方法吗?

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

    public override void Down()
    {
    }
}

up() 和 down() 方法的打印屏幕

DbContext 的打印屏幕

标签: c#asp.netentity-framework-6

解决方案


This was resolved by enabling the authentication option at the beginning. This creates a model called IdentityModel.cs which has the code for creating the methods in the up() and down() methods.

Print screen


推荐阅读