5

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.

1

1 Answer 1

9

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; }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.