C# 调试实体框架模型生成异常

C# 调试实体框架模型生成异常,c#,.net,entity-framework-6,C#,.net,Entity Framework 6,我犯了错误 序列包含多个匹配元素 在我的ASP.NET MVC项目中将EF从6.1.0-beta1升级到最新的6.1.3之后 堆栈跟踪包含在下面,因为它显示了在构建模型期间引发的异常,所以我假设我的模型存在一个问题,该问题在以前的EF版本中是正常的(我的模型没有更改),但是,由于我的模型相当广泛,我一直在到处寻找一种方法来获取有关发生问题的特定表/类的任何信息 我已尝试在VS中启用调试.NET framework代码,以查看是否可以在调试器中达到异常,但它无法下载Entity framework

我犯了错误

序列包含多个匹配元素

在我的ASP.NET MVC项目中将EF从6.1.0-beta1升级到最新的6.1.3之后

堆栈跟踪包含在下面,因为它显示了在构建模型期间引发的异常,所以我假设我的模型存在一个问题,该问题在以前的EF版本中是正常的(我的模型没有更改),但是,由于我的模型相当广泛,我一直在到处寻找一种方法来获取有关发生问题的特定表/类的任何信息

我已尝试在VS中启用调试.NET framework代码,以查看是否可以在调试器中达到异常,但它无法下载Entity framework的调试符号。我尝试下载源代码,并将其构建为指向.pdb文件,但它不接受

我甚至尝试更改对我自己构建的EF的引用,但由于没有签名而出错

如何找出哪个实体/类/表有问题

更新:经过反复试验,从Entity Framework版本6.1.0更新到6.1.1时出现错误

[无效操作异常:序列包含多个匹配元素]
System.Linq.Enumerable.SingleOrDefault(IEnumerable'1源,Func'2谓词)+4380333
System.Data.Entity.ModelConfiguration.Configuration.Mapping.c__DisplayClass4a.b__47(ForeignKeyBuilder fk)+178
System.Data.Entity.Utilities.IEnumerableExtensions.Each(IEnumerable'1TS,Action'1Action)+130
System.Data.Entity.ModelConfiguration.Configuration.Mapping.ForeignKeyPrimitiveOperations.RemoveAllForeignKeyConstraintsForColumn(EntityType表、EdmProperty列、DbDatabaseMapping databaseMapping)+155
System.Data.Entity.ModelConfiguration.Configuration.Mapping.EntityMappingConfiguration.CleanupUnmappedArtartIFacts(DbDatabaseMapping databaseMapping,EntityType table)+1312
System.Data.Entity.ModelConfiguration.Configuration.Mapping.EntityMappingConfiguration.Configure(DbDatabaseMapping databaseMapping、ICollection'1 entitySets、DbProviderManifest providerManifest、EntityType EntityType、EntityTypeMapping和EntityTypeMapping、Boolean IsMappingAnyInheritatedProperty、Int32 configurationIndex、Int32 configurationCount、IDictionary'2 commonAnnotations)+1719
System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigureTablesAndConditions(EntityTypeMapping EntityTypeMapping、DbDatabaseMapping databaseMapping、ICollection'1 entitySets、DbProviderManifest providerManifest)+155
System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntityTypes(DbDatabaseMapping databaseMapping,ICollection'1 entitySets,DbProviderManifest providerManifest)+105
System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration(DbDatabaseMapping databaseMapping,DbProviderManifest providerManifest)+361
System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest,DbProviderInfo providerInfo)+434
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)+55
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext)+62
System.Data.Entity.Internal.RetryLazy'2.GetValue(TInput输入)+123
System.Data.Entity.Internal.LazyInternalContext.InitializeContext()+627
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(类型entityType)+18
System.Data.Entity.Internal.Linq.InternalSet'1.Initialize()+53
System.Data.Entity.Internal.Linq.InternalSet'1.GetEnumerator()+15
System.Data.Entity.Infrastructure.DbQuery'1.System.Collections.Generic.IEnumerable.GetEnumerator()+53
System.Collections.Generic.List'1..ctor(IEnumerable'1 collection)+375
System.Linq.Enumerable.ToList(IEnumerable'1源)+58
C:\Users\Martin\Source\Repos\Scanboat\Scanboat2014\Repositories.ScanboatAdRepository..ctor()中的Scanboat2014.Repositories.ScanboatAdRepository.cs:26
C:\Users\Martin\Source\Repos\Scanboat\Scanboat2014\Controllers\HomeController.cs:18中的Scanboat2014.Controllers.HomeController..ctor()


在您的模型中看起来像是重复的外键名称。感谢gert arnold,这有助于缩小搜索范围,但正如前面提到的,我的模型非常全面,很难找到位置,奇怪的是,它只会在6.1.1中出错,而不会在6.1.0中出错。注释掉代码块会很糟糕,因为删除一个实体需要很多时间整个代码中的f引用也将被注释掉。我希望以某种方式获得调试信息,以找出重复出现的位置。