如果我们只更改数据注释的显示属性,我们还需要 运行 Add-Migration

Do we still need to run Add-Migration if we change only Display attribute of data Annotation

:此问题与Migrations - EF Core with ASP.NET Core MVC

相关

下面我只需要在Display Annotation中将FY1改为FY2即可。同样,我们各种模型的许多地方都有相似的 Display 值。由于模式没有改变,我假设我不需要再次 运行 PM>Add-migrationPM>Update-Database commands,对吗?

**Model**
...
[Display(Name = "FY1 Total Revenue")]
public float? FY2Rev { get; set; }
...

根据 MSDN:

The Migrations feature enables you to change the data model and deploy your changes to production by updating the database schema without having to drop and re-create the database.

与您的问题特别相关,更改 属性 的 Display 数据注释对数据库架构的影响为零。因为数据库为什么要关心您希望如何显示信息?您必须 运行 迁移的唯一原因是 如果 您决定更改 实际 属性 名称 。这种类型的更改必须在您的数据库中更新,以便在您更改域模型后收集正确的信息。

此外,更改 属性 type 将需要您进行迁移,因为您要明确更改 属性,特别是 属性 的类型。数据库将需要知道该更改以便收集正确的数据。

希望对您有所帮助。