实体框架不生成ObservableCollection [英] Entity Framework does not generates ObservableCollection
问题描述
替换ICollection和HashSet在 .tt
文件中的ObservableCollection。
然后搜索方法 public string UsingDirectives
。
在这种方法中应该有一行 includeCollections? (Environment.NewLine +using System.Collections.Generic;):,
。仅将 Generic
与 ObjectModel
替换。这将包括在模型中使用ObservableCollections的正确命名空间。
Im using EF6 in my dataentry program. EF does not generates ObservableCollection but HashSet and ICollection instead , so i have to change it manually. Unfortunately every time i Update Model from Database , every Many-Many relation goes back to ICollection ...
Replace ICollection and HashSet with ObservableCollection in your .tt
file.
Then search for the method public string UsingDirectives
.
In this method there should be a line includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
.
Replace only Generic
with ObjectModel
. This will include the correct namespace to use ObservableCollections in your models.
这篇关于实体框架不生成ObservableCollection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!