Entity Framework 6 NotMapped attributes

ef-fluent-api entity-framework entity-framework-6 fluent

Question

Is it possible to manually add ICollections that have been [NotMapped] to the model using the fluentAPI in a DbContext? I am aware of how to use the fluentAPI to manually ignore properties.

modelBuilder.Entity<MyEntity>().Ignore(e => e.MyChildCollection);

But can the property be "brought back" into the model if it was defined with the [NotMapped] attribute (see below)?

[NotMapped]
public virtual ICollection<ChildEntityType> MyChildCollection { get; set; }
1
0
5/14/2015 11:12:20 AM

Popular Answer

Yes, that is true. The [NotMapped] Data Annotation only has to be removed before you visit your Package Console Manager. Add-migration might be any name. Type update-database after that. The adjustments will be made automatically.

0
5/14/2015 11:16:26 AM


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