model first中不提供设置属性为NotMapped(不保存到数据库)的功能,设计器中添加的所有属性都会保存到数据库中。
model first模式下,若要将某个属性设置为不保存到数据库,可以使用partial类,在该属性上方加上NotMapped特性。
[NotMapped]
public int Age
{
get
{
return DateTime.Now.Year - Birthday.Value.Year;
}
}
model first中不提供设置属性为NotMapped(不保存到数据库)的功能,设计器中添加的所有属性都会保存到数据库中。
model first模式下,若要将某个属性设置为不保存到数据库,可以使用partial类,在该属性上方加上NotMapped特性。
[NotMapped]
public int Age
{
get
{
return DateTime.Now.Year - Birthday.Value.Year;
}
}