2

Closed

'Shared Columns': The item with identity 'SomeSharedColumn' already exists in the metadata collection.

description

I am trying this with EntityFramework.6.0.0-alpha3-20420

Further to the issue https://entityframework.codeplex.com/workitem/1021 and https://entityframework.codeplex.com/workitem/583. I am seeing this error with "Shared Columns". See attachment for repro. Stack Trace:
   at System.Data.Entity.Core.Metadata.Edm.MetadataCollection`1.AddToDictionary(Dictionary`2 identityDictionary, List`1 orderedList, String identity, Int32 index, Boolean updateIfFound)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCollection`1.<InvalidateCache>b__0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at System.Data.Entity.Core.Metadata.Edm.MetadataCollection`1.IndexOf(CollectionData collectionData, String identity, Boolean ignoreCase)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCollection`1.IndexOf(T item)
   at System.Data.Entity.Core.Metadata.Edm.MemberCollection.IndexOf(EdmMember item)
   at System.Data.Entity.Core.Metadata.Edm.MetadataCollection`1.Contains(T item)
   at System.Data.Entity.Core.Metadata.Edm.StructuralType.HasMember(EdmMember member)
   at System.Data.Entity.ModelConfiguration.Configuration.TphColumnFixer.RemoveDuplicateTphColumns()
   at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.RemoveDuplicateTphColumns(DbDatabaseMapping databaseMapping)
   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)
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.OfType[TResult](IQueryable source)
   at EF6Test.Program.Main(String[] args) in c:\Users\Ben\Documents\Visual Studio 11\Projects\EF6Test\EF6Test\Program.cs:line 16
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

file attachments

Closed May 1, 2013 at 5:12 PM by lukew
Verified Fixed

comments

RoMiller wrote Apr 25, 2013 at 11:21 PM

EF Team Triage: Assigning to a member of the EF team for further investigation.

ajcvickers wrote Apr 29, 2013 at 6:30 PM

Fixed in 0ae1b0c89d6b

YourSecretIdentityIsDiscovered (Uniquify identity instead of name when setting name explicitly)

This was an issue with the code that temporarily uniquifies identities when multiple column names are explicitly set to the same name but then all but one are removed. In cases where there are a lot of columns in the collection (so that metadata does its collection handling flip) this was causing issues because the names were uniquified but the identities were colliding. The fix is to make sure that identities are uniquified in this case.

gichamba wrote May 2, 2013 at 6:54 AM

Thank you,
The error is no longer there in all the situations it was showing up.
Will keep testing to make sure we have uncovered all the "Shared Column" issues before EF6 release.
It's such a great feature.