1

Entity Framework 将所有属性作为数据库中的字段如何使Entity不创建一个或多个属性作为数据库字段?

4

2 回答 2

2

您可以使用 C# 属性NotMapped,使实体框架在尝试将其映射到数据库列时忽略该属性。

[NotMapped]
public string PropertyThatShouldntBeInDatabase {get;set;}
于 2013-07-17T18:28:52.360 回答
1

您可以在 Attribute 之前使用 NotMapped

[NotMapped]
public string Username{get; set;}
于 2013-07-17T18:31:34.420 回答