【发布时间】:2019-05-03 14:51:12
【问题描述】:
我的团队使用 Db 优先设计。 我们创建数据库,然后使用 Scaffold-DbContext 命令创建模型。
问题是当我们需要修改模型然后重新创建时。
public partial class UserInfo
{
public int Id { get; set; }
[Required]
public string FirstName { get; set; }
public string LastName { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public DateTime RecordCreated { get; set; }
}
在使用 -Force 调用 Scaffold-DbContext 时,它将从中删除 [Required]。
我应该考虑使用 ViewModel、创建部分类还是什么?
很早就使用 EF core 2.1,因此我们将不胜感激。
乔
【问题讨论】:
标签: c# entity-framework entity-framework-core