.NET核心更新迁移正在尝试重新创建表

.NET核心更新迁移正在尝试重新创建表,.net,entity-framework,asp.net-core,.net-core,entity-framework-core,.net,Entity Framework,Asp.net Core,.net Core,Entity Framework Core,我首先在做一个.NETCore3项目代码。在这一步中,我向表中添加了两列。然后,我通过这段代码(CLI)向解决方案添加了一个迁移 我的迁移返回了以下内容: public partial class actorInfomart : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn<b

我首先在做一个.NETCore3项目代码。在这一步中,我向表中添加了两列。然后,我通过这段代码(CLI)向解决方案添加了一个迁移

我的迁移返回了以下内容:

public partial class actorInfomart : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
        migrationBuilder.AddColumn<bool>(
            name: "IsSeries",
            schema: "film",
            table: "Movie",
            nullable: false,
            defaultValue: false);

        migrationBuilder.AddColumn<string>(
            name: "ExtInfo",
            schema: "act",
            table: "Actor",
            maxLength: 100,
            nullable: true);
    }

    protected override void Down(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.DropColumn(
            name: "IsSeries",
            schema: "film",
            table: "Movie");

        migrationBuilder.DropColumn(
            name: "ExtInfo",
            schema: "act",
            table: "Actor");
    }
}
我的迁移正在尝试在数据库中创建新表。但在移民中,这是不可能的。这是我的migration update CLI命令

dotnet ef --startup-project ../MyApi.Api database update actorInfomart
在终端(我使用Mac)中写入


如何应用最新的迁移?我在第一次和最后一次之间进行了10次迁移。这是我关于迁移的第一个问题。

我在数据库中看到了这个问题。因为截断了数据库中的“EFMigrationsHistory”表。由于未应用任何迁移,系统的行为正在转变为初始迁移。

在数据库中,您有一个表u migrations u History,所有应用的迁移都必须保存在该表中。如果未应用,但已应用(表已创建或更新),则当您再次尝试应用时,将抛出一个例外,即当您创建模型时,该表已存在,但您没有为第一次迁移应用更新。另请注意:迁移始终基于快照(在Migrations文件夹中),而不是运行
dotnet ef Migrations add
commandI截断表时的实际数据库布局,因此它也截断了迁移表。我了解到ef正在寻找移民申请表。
There is already an object named 'Actor' in the database.
dotnet ef --startup-project ../MyApi.Api database update actorInfomart
info: Microsoft.EntityFrameworkCore.Migrations[20402]
      Applying migration '20191231100058_Initial'.
Applying migration '20191231100058_Initial'.