C# EF代码第一个排除列
可能重复:C# EF代码第一个排除列,c#,entity-framework,ef-code-first,C#,Entity Framework,Ef Code First,可能重复: 我首先使用EF4代码 是否有任何方法可以排除在数据库中创建列 例如,我想排除要创建的Zip列 public string Address { get; set; } [StringLength(40)] public string City { get; set; } [StringLength(30)] public string State { get; set; } [StringLength(10)] public string Zip { get; set; } 谢谢。
我首先使用EF4代码 是否有任何方法可以排除在数据库中创建列 例如,我想排除要创建的
Zip
列
public string Address { get; set; }
[StringLength(40)]
public string City { get; set; }
[StringLength(30)]
public string State { get; set; }
[StringLength(10)]
public string Zip { get; set; }
谢谢。您可以向要从数据库中排除的属性添加
[NotMapped]
属性:
public string Address { get; set; }
[StringLength(40)]
public string City { get; set; }
[StringLength(30)]
public string State { get; set; }
[StringLength(10)]
[NotMapped]
public string Zip { get; set; }
见此帖: