Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# EF代码第一个排除列_C#_Entity Framework_Ef Code First - Fatal编程技术网

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; }
见此帖: