[英]How to add attributes to entity framework model class without losing them after update database
我想在我的 model class 内的属性上添加属性。 但我知道如果我在数据库中创建新的更改并更新我的 model,添加的属性将被删除。 So my question is can I manipulate the model class into a POCO and reference the POCO instead of using EF model class when I do IQueryables.
public IQueryable<UserAccount> GetUserAccounts()
{
return Entity.UserAccounts;
}
UserAccount
是由 EF 创建的自动生成的模板 model class。 我可以拥有自己的 model 来进行数据注释吗?
Hy,最好的方法是保持自动生成的 class 保持原样,这样可以使其更干净,并使用包含所需额外属性的部分 class 扩展 class。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.