实体框架数据库优先和“覆盖”关键字
本文关键字:覆盖 关键字 框架 数据库 实体 | 更新日期: 2023-09-27 18:31:27
假设我有这个类
public class Parent {
virtual string Name {get; set;}
}
public partial class Child : Parent {
}
当我第一次使用 EF DB 时,它会生成以下内容:
public partial class Child {
string Name {get; set;}
}
如何让它使用"override
"关键字作为名称?我不想每次更新数据库时都添加它。
如果要
使用继承创建模型,请检查以下链接:
实体框架 DB-优先,实现继承
http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application
如果要将数据库中不在数据库中的新属性创建到模型中的现有类,请尝试使用分部类:https://msdn.microsoft.com/pt-br/library/wa80x488.aspx