有没有一种方法可以在DbContext中使用fluentAPI来手动将已被NotMapped的ICollections包含在模型中?我知道如何使用fluentAPI手动忽略属性
modelBuilder.Entity<MyEntity>().Ignore(e => e.MyChildCollection);但是如果属性是用NotMapped属性定义的(见下文),它能被“带回”到模型中吗?
[NotMapped]
public virtual ICollection<ChildEntityType> MyChildCollection { get; set; }发布于 2015-05-14 19:16:27
是的,有可能。您只需删除NotMapped数据注释,然后转到包控制台管理器。键入add-migration anyname。然后输入update-database。它将自动进行更改。
https://stackoverflow.com/questions/30235897
复制相似问题