Sunday, 29 September 2013

Entity Framework - How to prevent a prevent a model property from column creation?

Entity Framework - How to prevent a prevent a model property from column
creation?

Folks,
I am developing an web application based on ASP .NET MVC 4.
Let's say I define a model such as:
public class MyUser {
public string UserName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
The database initializer code will automatically create a table with three
columns - UserName, FirstName, and LastName.
However, let's say I don't want LastName to be part of the database table.
Is there any data annotation attribute that I can use to prevent a
property from being exposed as a column?
Thank you in advance for your help.
Regards,
Peter

No comments:

Post a Comment