2012-03-02 56 views
2

我試圖將我的解決方案從EF Code First的2011年6月CTP升級到EF 5 Beta。EF 5 Beta 1代碼優先 - 序列包含多個元素

現在我有以下問題:

創建上下文的一個實例後,我得到下面當我嘗試和查詢上下文中列出的除外。

似乎在EF的兩個版本之間,有些事情已經發生了變化,現在它在處理配置時遇到了問題,但我無法從哪裏開始尋找。

非常感謝您的任何幫助。

Paul。

System.InvalidOperationException了由用戶代碼未處理
的HResult = -2146233079消息=序列包含一個以上的元件 源= System.Core程序堆棧跟蹤: 在System.Linq.Enumerable.SingleOrDefault [TSource](IEnumerable的 TS,動作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輸入) 在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() at AccessAccounts.Accounts.DataAccess.Context.AccountsContext..ctor(String connectionString)in c:\ Source \ EnterpriseVS11 \ Enterprise \ Data Access EF \ Context \ AccountsContext.cs:line 77 at AccessAccounts.BusinessService.Logon.LogonService.CheckDatabaseCompatibility() in c:\ Source \ EnterpriseVS11 \ Enterprise \ Business Service \ src \ AccessAccounts \ BusinessService \ Logon \ LogonService.cs:行 at AccessAccounts.BusinessService.Logon.LogonService.Logon(ApplicationTypes applicationType,String databaseName,String userName,String password,AuthenticationType authenticationMode)在 C:\源\ EnterpriseVS11 \企業\商業 服務\ SRC \ AccessAccounts \的BusinessService \登錄\ LogonService.cs:線在SyncInvokeLogon(對象,對象[],對象[]) 在系統。 ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(對象 例如,對象[]輸入,對象[] &輸出) 在System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc & RPC)的InnerException:

+0

你可以提供查詢周圍的代碼嗎?它看起來像SingleOrDefault()的問題。 – WDRust 2012-03-02 23:07:56

+1

似乎這是一個已知的錯誤https://twitter.com/#!/divega/status/175984297931583489 - 可悲的是,我遇到了同樣的事情。 – rafek 2012-03-03 17:24:30

+0

@rafek - 謝謝,我希望他們儘快修復或者可以提供解決方法。如果我得到時間,我可以試着追查它在配置中的情況,它不喜歡,假設這是它的原因。我非常熱衷於嘗試EF 5來觀察這些性能改進! – P2l 2012-03-03 18:38:18

回答

2

這是這是EF5 Beta 1中的一個已知錯誤。我們將在Beta 2中修復此問題,這將是d在接下來的幾個星期內將會出現。

該錯誤僅影響獨立關聯(在您的CLR類中不存在FK的關聯),因此您可以通過切換到FK關聯來解決此問題。

+0

謝謝,期待修復。 – P2l 2012-03-05 21:22:10

+0

我可以確認EF5 Beta 2已經修復了這個問題。 – P2l 2012-03-25 19:14:27