When using Entity Framework Code First, how to disregard a property

code-first entity-framework

Question

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?

1
56
7/29/2015 3:01:29 PM

Accepted Answer

124
1/8/2013 12:23:09 AM

Popular Answer

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);
}


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow