EF code Exclude column first

Possible duplicate:
Exclude field / property from database using Entity Framework 4 and Code-First

I use the EF 4 code first.

Is there any way to exclude the creation of a column in the database?

For example, I want to exclude the created Zip column.

 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; } 

Thanks.

+4
source share
1 answer

You can add the [NotMapped] attribute to the property that you want to exclude from the database:

 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; } 
+7
source

Source: https://habr.com/ru/post/1437767/


All Articles