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

code-first entity-framework

Question

Code for Entity Framework The database base will first automatically construct a table based on the model.

Exists a quality that will prevent this?

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

Accepted Answer

To the property, add the [System.ComponentModel.DataAnnotations.Schema.NotMapped] attribute.

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

Popular Answer

The accepted response and similar query and response also signify that[NotMapped] Additionally, you may do so by utilizing 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