Possible Duplicate:
Exclude a field/property from the database with Entity Framework 4 & Code-First
I am using EF 4 code-first.
Is there any method to exclude creating a column into the database?
For example I want to exclude the Zip
column to be created.
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; }
Thank you.
You can add a [NotMapped]
attribute to the property 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; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With