EF 5 Beta 1 Code First - 序列包含多个元素

时间:2012-03-02 15:14:13

标签: entity-framework ef-code-first

我正在尝试将我的解决方案从2011年6月的EF Code First CTP升级到EF 5 Beta。

我现在遇到以下问题:

创建上下文的实例后,当我尝试查询上下文时,我得到下面列出的异常。

似乎在两个版本的EF之间出现了一些变化,现在它在处理配置方面遇到了问题,但我不知道从哪里开始寻找。

非常感谢您的任何帮助。

保罗。

  

System.InvalidOperationException未被用户代码
处理   HResult = -2146233079 Message = Sequence包含多个元素   Source = System.Core StackTrace:          在System.Linq.Enumerable.SingleOrDefault [TSource](IEnumerable 1 source) at System.Data.Entity.ModelConfiguration.Configuration.Properties.Navigation.NavigationPropertyConfiguration.Configure(DbDatabaseMapping databaseMapping) at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.<>c__DisplayClass36.<ConfigureAssociationMappings>b__35(NavigationPropertyConfiguration c) at System.Data.Entity.ModelConfiguration.Utilities.IEnumerableExtensions.Each[T](IEnumerable 1   ts,Action 1 action) at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigureAssociationMappings(DbDatabaseMapping databaseMapping) at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EdmEntityType entityType, DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntityTypes(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo) at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) at System.Data.Entity.Internal.RetryLazy 2.GetValue(TInput input)          在System.Data.Entity.Internal.LazyInternalContext.InitializeContext()          在System.Data.Entity.Internal.InternalContext.Initialize()          在System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes()          at System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()          在AccessAccounts.Accounts.DataAccess.Context.AccountsContext..ctor(String   connectString在c:\ Source \ EnterpriseVS11 \ Enterprise \ Data Access中   EF \ Context \ AccountsContext.cs:第77行          在AccessAccounts.BusinessService.Logon.LogonService.CheckDatabaseCompatibility()   在c:\ Source \ EnterpriseVS11 \ Enterprise \ Business中   服务的\ src \ AccessAccounts \的BusinessService \登录\ LogonService.cs:行   119          在AccessAccounts.BusinessService.Logon.LogonService.Logon(ApplicationTypes   applicationType,String databaseName,String userName,String   密码,AuthenticationType authenticationMode)   C:\来源\ EnterpriseVS11 \企业\业务   服务的\ src \ AccessAccounts \的BusinessService \登录\ LogonService.cs:行   255          在SyncInvokeLogon(Object,Object [],Object [])          在System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object   实例,对象[]输入,对象[]&amp;输出)          在System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;   rpc)InnerException:

1 个答案:

答案 0 :(得分:2)

这是EF5 Beta 1中的一个已知错误。我们将在Beta 2中修复此问题,该问题将在未来几周内完成。

该错误仅影响独立关联(CLR类中不存在FK的关联),因此您可以通过切换到FK关联来解决此问题。