我遇到了错误
序列包含多个匹配元素
在我的ASP.NET MVC项目中将EF从6.1.0-beta1升级到最新的6.1.3之后。
堆栈跟踪包含在下面,因为它显示了在模型构建期间抛出的异常,我认为我的模型存在问题,在之前的EF版本中没问题(我的模型没有改变) ),但由于我的模型相当广泛,我一直在搜索高低,以获取有关出现问题的特定表/类的任何信息。
我已经尝试在VS中调试.NET框架代码以查看我是否可以在调试器中达到异常,但无法下载Entity Framework的调试符号。我尝试下载源代码,并将其构建为指向.pdb文件,但它不会接受它。
我甚至尝试更改对我自己的EF版本的引用,但因为没有签名而收到错误。
如何找出哪个实体/类/表有问题?
更新:通过反复试验,结果表明从Entity Framework V6.1.0更新到6.1.1时出现错误。
[InvalidOperationException:Sequence包含多个匹配元素]
System.Linq.Enumerable.SingleOrDefault(IEnumerable' 1 source,Func' 2谓词)+4380333
System.Data.Entity.ModelConfiguration.Configuration.Mapping。<> c__DisplayClass4a.b__47(ForeignKeyBuilder fk)+177
System.Data.Entity.Utilities.IEnumerableExtensions.Each(IEnumerable' 1 ts,Action' 1 action)+130
System.Data.Entity.ModelConfiguration.Configuration.Mapping.ForeignKeyPrimitiveOperations.RemoveAllForeignKeyConstraintsForColumn(EntityType表,EdmProperty列,DbDatabaseMapping databaseMapping)+155
System.Data.Entity.ModelConfiguration.Configuration.Mapping.EntityMappingConfiguration.CleanupUnmappedArtifacts(DbDatabaseMapping databaseMapping,EntityType table)+1312
System.Data.Entity.ModelConfiguration.Configuration.Mapping.EntityMappingConfiguration.Configure(DbDatabaseMapping databaseMapping,ICollection' entitySets,DbProviderManifest providerManifest,EntityType entityType,EntityTypeMapping& entityTypeMapping,Boolean isMappingAnyInheritedProperty,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.Configure(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 internalContext)+62
System.Data.Entity.Internal.RetryLazy' 2.GetValue(T输入输入)+123
System.Data.Entity.Internal.LazyInternalContext.InitializeContext()+627
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type 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
Scanboat2014.Repositories.ScanboatAdRepository..ctor()在C:\ Users \ Martin \ Source \ Repos \ Scanboat \ Scanboat2014 \ Repositories \ ScanboatAdRepository.cs:26
Scanboat2014.Controllers.HomeController..ctor()在C:\ Users \ Martin \ Source \ Repos \ Scanboat \ Scanboat2014 \ Controllers \ HomeController.cs:18