【发布时间】:2022-01-01 11:19:03
【问题描述】:
我正在创建一个 MVC ASP.NET Core 3.1 Web 应用程序,并在项目的中间向 ApplicationUser 类添加了以下属性和注释。
[Display(Name = "First Name")]
[StringLength(100, ErrorMessage = "The {0} can't have more than 100 characters.")]
public string FirstName { get; set; }
[Display(Name = "Last Name")]
[StringLength(100, ErrorMessage = "The {0} can't have more than 100 characters.")]
public string LastName { get; set; }
[Display(Name = "Date Of Birth")]
public DateTime DateOfBirth { get; set; }
public string Country { get; set; }
但是,在向 DateOfBirth 添加另一个注释之前,我不小心运行了 add-migration 和 update-database:
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
改正错误的方法是什么?我现在如何添加注释? 谢谢。
【问题讨论】:
标签: c# asp.net-mvc asp.net-core data-annotations asp.net-core-3.1