Suppress Columns in Entity Framework Code First

I’m not a big fan of “Code First”. One issue with deriving table design from object model is that object model frequently includes properties that we don’t want to appear as columns in database. The most common example of this are read-only properties whose values are calculated internally from other properties in the object.
You can use the NotMapped Annotation to instruct Code-First to exclude a particular property.

public class Customer
public int CustomerID { set; get; }
public string FirstName { set; get; }
public string LastName{ set; get; }
public int Age { set; get; }

That’s it.
Hope this will help !!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s