Entity Framework Code First will auto-create a table in the database base based on the Model.
Is there an attribute that will avoid this?
Entity Framework Code First will auto-create a table in the database base based on the Model.
Is there an attribute that will avoid this?
Add the [System.ComponentModel.DataAnnotations.Schema.NotMapped]
attribute to the property.
Per the accepted answer and similar question/answer, in addition to [NotMapped]
you can also specify it using the Fluent API:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<TheModelAffected>().Ignore(t => t.TheIgnoredProperty);
base.OnModelCreating(modelBuilder);
}