Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude a field/property from the database with Entity Framework 4 & Code-First

I will like to know that is there a way to exclude some fields from the database? For eg:

public class Employee {     public int Id { get; set; }     public string Name { get; set; }     public string FatherName { get; set; }      public bool IsMale { get; set; }     public bool IsMarried { get; set; }      public string AddressAs { get; set; } } 

How can I exclude the AddressAs field from the database?

like image 636
Yogesh Avatar asked Nov 10 '09 12:11

Yogesh


1 Answers

for future reference: you can use data annotations MSDN EF - Code First Data Annotations

[NotMapped]         public string AddressAs { get; set; } 
like image 181
markwilde Avatar answered Oct 13 '22 22:10

markwilde