An item with the same key has already been added.

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 17-Dec-2012 16:36:45   

It doesn't like my composite key inheritance hierarchy...

<?xml version="1.0" encoding="utf-8"?>
<!--LLBLGen Pro v3.1 project file. Do not manually edit this file. Incorrect references could lead to an unloadable project file.-->
<Project Version="3.1" TargetFrameworkName="LLBLGen Pro Runtime Framework">
  <Properties>
    <Abbreviations />
    <Property Name="AdditionalTaskPerformerFolder" Value="" />
    <Property Name="AdditionalTasksFolder" Value="" />
    <Property Name="AdditionalTemplatesFolder" Value="" />
    <Property Name="AdditionalTypeConverterFolder" Value="" />
    <Property Name="AddNewElementsAfterRefresh" Value="0" />
    <Property Name="AddNewFieldsAfterRefresh" Value="0" />
    <Property Name="AddNewViewsAsEntitiesAfterRefresh" Value="0" />
    <Property Name="AutoAddManyToManyRelationships" Value="false" />
    <Property Name="AutoAssignSequencesToIntegerPks" Value="true" />
    <Property Name="AutoAssignTypeConverterToFieldMapping" Value="false" />
    <Property Name="CleanUpVsNetProjects" Value="true" />
    <Property Name="ConnectionStringKeyNamePattern" Value="ConnectionString.{$ProviderName}" />
    <Property Name="EncodingToUse" Value="0" />
    <Property Name="EnforcePascalCasingAlways" Value="true" />
    <Property Name="EntityFieldNameStripPattern" Value="{}{}" />
    <Property Name="EntityNameStripPattern" Value="{tbl_}{}" />
    <Property Name="ExcludableOrphanedElementDetectedAction" Value="3" />
    <Property Name="FailCodeGenerationOnWriteError" Value="false" />
    <Property Name="FieldMappedOntoRelatedFieldPattern" Value="{$RelatedFieldName}" />
    <Property Name="FkFieldsAreNamedAfterTargetField" Value="true" />
    <Property Name="ForeignKeyFieldPattern" Value="{$NavigatorName}{$RelatedFieldName}" />
    <Property Name="GroupUsage" Value="0" />
    <Property Name="IdentifyingFieldsFollowDBPrimaryKeyConstraints" Value="0" />
    <Property Name="InsertUnderscoreAtWordBreakCaseSensitiveDBs" Value="false" />
    <Property Name="LengthPrecisionScaleFollowDBLengthPrecisionScale" Value="0" />
    <Property Name="MakeElementNamePascalCasing" Value="true" />
    <Property Name="NavigatorMappedOntoManyToManyPattern" Value="{$EndEntityName}CollectionVia{$IntermediateEntityName$S}" />
    <Property Name="NavigatorMappedOntoOneManyToOnePattern" Value="{$EndEntityName$S}" />
    <Property Name="NavigatorMappedOntoOneToManyPattern" Value="{$EndEntityName$P}" />
    <Property Name="NonExcludableOrphanedElementDetectedAction" Value="3" />
    <Property Name="PreferDecimalOverCurrencyTypes" Value="true" />
    <Property Name="PreferNaturalCharacterTypes" Value="true" />
    <Property Name="PreferVariableLengthTypes" Value="true" />
    <Property Name="ProjectCreator" Value="Ian" />
    <Property Name="ProjectName" Value="Event Payment Method" />
    <Property Name="RelationalModelDataElementNameCasingCaseSensitiveDBs" Value="3" />
    <Property Name="RelationshipsFollowDBForeignKeyConstraints" Value="0" />
    <Property Name="RemoveUnderscoresFromElementName" Value="true" />
    <Property Name="RemoveUnmappedElementsAfterRefresh" Value="0" />
    <Property Name="ResetFieldOrderBasedOnTargetOrderAtRefresh" Value="false" />
    <Property Name="RetrieveDBCustomProperties" Value="false" />
    <Property Name="RootNamespace" Value="" />
    <Property Name="SequencePattern" Value="SEQ_{$EntityName}" />
    <Property Name="SetGroupNameAfterSchemaName" Value="true" />
    <Property Name="SetSchemaNameAfterGroupName" Value="true" />
    <Property Name="StoredProcNameStripPattern" Value="{pr_, sp_}{}" />
    <Property Name="StoreTimeLastGeneratedIntoProject" Value="false" />
    <Property Name="SyncMappedElementNamesAfterRefresh" Value="0" />
    <Property Name="SyncRelationalModelDataElementNameAfterRename" Value="0" />
    <Property Name="SyncRenamedMappedElementNamesAfterRefresh" Value="0" />
    <Property Name="TargetPerEntityEdgesRequireBackingFkConstraint" Value="true" />
    <Property Name="TypedViewFieldNameStripPattern" Value="{}{}" />
    <Property Name="TypedViewNameStripPattern" Value="{vw_}{}" />
    <Property Name="UniqueConstraintsFollowDBUniqueConstraints" Value="0" />
    <Property Name="UpdateCustomPropertiesAfterRefresh" Value="0" />
    <Property Name="UseCustomFieldOrderingOnNewElements" Value="false" />
  </Properties>
  <TypeShortcuts />
  <CodeGenerationMetaDataDefaults>
    <TargetElement Type="256">
      <OutputSettingValues>
        <Attributes>
          <Attribute Value="Browsable($false)" />
        </Attributes>
      </OutputSettingValues>
    </TargetElement>
  </CodeGenerationMetaDataDefaults>
  <EntityModel>
    <ValueTypeDefinitions />
    <EntityDefinitions>
      <EntityDefinition Name="EventPaymentPlan" InheritanceType="2">
        <Fields>
          <Field Name="Enabled" Type="bool" />
          <Field Name="EventId" Type="int" Precision="10" IsPrimaryKey="true" />
          <Field Name="PaymentPlanId" Type="int" Precision="10" IsPrimaryKey="true" />
        </Fields>
      </EntityDefinition>
      <EntityDefinition Name="EventPaymentPlanDeposit" InheritanceType="2">
        <Fields>
          <Field Name="DaysToPayBalance" Type="int" Precision="10" />
          <Field Name="DepositPercentage" Type="int" Precision="10" />
        </Fields>
      </EntityDefinition>
    </EntityDefinitions>
    <Relationships />
    <InheritanceHierarchies>
      <InheritanceHierarchy SuperType=":EventPaymentPlan" SubType=":EventPaymentPlanDeposit" />
    </InheritanceHierarchies>
  </EntityModel>
  <TargetDatabases>
    <TargetDatabase Type="2D18D138-1DD2-467E-86CC-4838250611AE">
      <ConnectionElements>
        <ConnectionElement Name="ServerName" Value="localhost" />
        <ConnectionElement Name="CatalogName" Value="master" />
        <ConnectionElement Name="UserID" Value="sa" />
        <ConnectionElement Name="Password" Value="" />
      </ConnectionElements>
      <SystemSequences>
        <Sequence Name="SCOPE_IDENTITY()" />
        <Sequence Name="@@IDENTITY" />
      </SystemSequences>
      <Catalogs>
        <Catalog Name="bangfaceweekender">
          <Schemas>
            <Schema Name="dbo">
              <Tables>
                <Table Name="tbl_event">
                  <Fields>
                    <Field Name="EventID" Ordinal="1" IsIdentity="true" IsPrimaryKey="true" PkConstraintName="PK_tbl_event" DbType="8" Precision="10" />
                    <Field Name="BrandId" Ordinal="2" DefaultValue="((2))" DbType="8" Precision="10" />
                    <Field Name="Name" Ordinal="3" DbType="24" Length="200" />
                    <Field Name="Date" Ordinal="4" DbType="4" />
                    <Field Name="EventCategoryID" Ordinal="5" DbType="8" Precision="10" />
                    <Field Name="BangfaceIndex" Ordinal="6" DbType="8" Precision="10" />
                    <Field Name="Live" Ordinal="7" DbType="2" />
                    <Field Name="VenueID" Ordinal="8" DbType="8" Precision="10" />
                    <Field Name="EndDate" Ordinal="9" DbType="4" />
                    <Field Name="AccountLockTypeId" Ordinal="10" DbType="8" Precision="10" />
                    <Field Name="LockAccountLeaders" Ordinal="11" DbType="2" />
                    <Field Name="EnableUpgrades" Ordinal="12" DefaultValue="((1))" DbType="2" />
                  </Fields>
                </Table>
                <Table Name="tbl_event_payment_plan">
                  <Fields>
                    <Field Name="EventId" Ordinal="1" IsPrimaryKey="true" PkConstraintName="PK_tbl_event_payment_type" DbType="8" Precision="10" />
                    <Field Name="PaymentPlanId" Ordinal="2" IsPrimaryKey="true" PkConstraintName="PK_tbl_event_payment_type" DbType="8" Precision="10" />
                    <Field Name="Enabled" Ordinal="3" DbType="2" />
                  </Fields>
                </Table>
                <Table Name="tbl_event_payment_plan_deposit">
                  <Fields>
                    <Field Name="EventId" Ordinal="1" IsPrimaryKey="true" PkConstraintName="PK_tbl_deposit_payment_plan_1" DbType="8" Precision="10" />
                    <Field Name="PaymentPlanId" Ordinal="2" TrackedChanges="512" PkConstraintName="PK_tbl_deposit_payment_plan_1" DbType="8" Precision="10" />
                    <Field Name="DepositPercentage" Ordinal="3" DbType="8" Precision="10" />
                    <Field Name="DaysToPayBalance" Ordinal="4" DbType="8" Precision="10" />
                  </Fields>
                </Table>
                <Table Name="tbl_payment_plan">
                  <Fields>
                    <Field Name="PaymentPlanCategoryId" Ordinal="1" IsPrimaryKey="true" PkConstraintName="PK_tbl_payment_plan_category" DbType="8" Precision="10" />
                    <Field Name="Name" Ordinal="2" DbType="24" Length="50" />
                  </Fields>
                </Table>
              </Tables>
            </Schema>
          </Schemas>
          <ForeignKeyConstraints>
            <ForeignKeyConstraint Name="dbo:tbl_event_payment_plan:FK_tbl_event_payment_type_tbl_event">
              <FieldPairs>
                <FieldPair PkField="dbo:tbl_event:EventID" FkField="dbo:tbl_event_payment_plan:EventId" />
              </FieldPairs>
            </ForeignKeyConstraint>
            <ForeignKeyConstraint Name="dbo:tbl_event_payment_plan:FK_tbl_event_payment_type_tbl_payment_plan">
              <FieldPairs>
                <FieldPair PkField="dbo:tbl_payment_plan:PaymentPlanCategoryId" FkField="dbo:tbl_event_payment_plan:PaymentPlanId" />
              </FieldPairs>
            </ForeignKeyConstraint>
            <ForeignKeyConstraint Name="dbo:tbl_event_payment_plan_deposit:FK_tbl_deposit_payment_plan_tbl_event_payment_plan">
              <FieldPairs>
                <FieldPair PkField="dbo:tbl_event_payment_plan:EventId" FkField="dbo:tbl_event_payment_plan_deposit:EventId" />
                <FieldPair PkField="dbo:tbl_event_payment_plan:PaymentPlanId" FkField="dbo:tbl_event_payment_plan_deposit:PaymentPlanId" />
              </FieldPairs>
            </ForeignKeyConstraint>
          </ForeignKeyConstraints>
        </Catalog>
      </Catalogs>
    </TargetDatabase>
  </TargetDatabases>
  <MappingStores>
    <MappingStore Type="2D18D138-1DD2-467E-86CC-4838250611AE">
      <EntityMappings>
        <EntityMapping EntityName=":EventPaymentPlan" TargetName="bangfaceweekender:dbo:tbl_event_payment_plan">
          <FieldMappings>
            <FieldMapping FieldName="Enabled" TargetFieldName="Enabled" />
            <FieldMapping FieldName="EventId" TargetFieldName="EventId" />
            <FieldMapping FieldName="PaymentPlanId" TargetFieldName="PaymentPlanId" />
          </FieldMappings>
        </EntityMapping>
        <EntityMapping EntityName=":EventPaymentPlanDeposit" TargetName="bangfaceweekender:dbo:tbl_event_payment_plan_deposit">
          <FieldMappings>
            <FieldMapping FieldName="DaysToPayBalance" TargetFieldName="DaysToPayBalance" />
            <FieldMapping FieldName="DepositPercentage" TargetFieldName="DepositPercentage" />
            <FieldMapping FieldName="EventId" TargetFieldName="EventId" />
            <FieldMapping FieldName="PaymentPlanId" TargetFieldName="EventId" />
          </FieldMappings>
        </EntityMapping>
      </EntityMappings>
      <TypedViewMappings />
      <SPCallMappings />
      <TypeConversionDefinitions />
    </MappingStore>
  </MappingStores>
  <ModelViews />
</Project>
Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 17-Dec-2012 19:10:25   

Please post the exception/error text. And which designer version (release date) is this?

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 18-Dec-2012 00:29:32   

An item with the same key has already been added.

LLBLGen Pro version 3.1. Build May 25th, 2011 -----[Core exception]-------------------- at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value) at SD.Tools.Algorithmia.GeneralDataStructures.KeyedCommandifiedList2.IndexElement(T toIndex) in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\GeneralDataStructures\KeyedCommandifiedList.cs:line 185 at SD.Tools.Algorithmia.GeneralDataStructures.KeyedCommandifiedList2.OnAddingItem(T item) in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\GeneralDataStructures\KeyedCommandifiedList.cs:line 122 at SD.Tools.Algorithmia.GeneralDataStructures.CommandifiedList1.PerformInsertItem(Int32 index, T item) in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\GeneralDataStructures\CommandifiedList.cs:line 515 at SD.Tools.Algorithmia.GeneralDataStructures.CommandifiedList1.<>c__DisplayClassc.<InsertItem>b__a() in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\GeneralDataStructures\CommandifiedList.cs:line 236 at SD.Tools.Algorithmia.Commands.Command1.Do() in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\Commands\Command.cs:line 178 at SD.Tools.Algorithmia.Commands.CommandQueue.PerformDoRedoCommand(Boolean performRedo) in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\Commands\CommandQueue.cs:line 151 at SD.Tools.Algorithmia.Commands.CommandQueue.DoCurrentCommand() in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\Commands\CommandQueue.cs:line 127 at SD.Tools.Algorithmia.Commands.CommandQueueManager.EnqueueAndRunCommand(CommandBase toEnqueueAndRun) in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\Commands\CommandQueueManager.cs:line 394 at SD.Tools.Algorithmia.Commands.Command1.DoNow(Action doFunc, Action undoFunc, String description) in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\Commands\Command.cs:line 161 at SD.Tools.Algorithmia.GeneralDataStructures.CommandifiedList1.InsertItem(Int32 index, T item) in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\GeneralDataStructures\CommandifiedList.cs:line 236 at System.Collections.ObjectModel.Collection1.Add(T item) at SD.LLBLGen.Pro.DBDriverCore.DBTable.CreateNewFkConstraintIfNecessary(List1 fieldPairs, Action1 messageReportingFunc, Boolean forModelOnlyRelationship) at SD.LLBLGen.Pro.ApplicationCore.MetaData.DatabaseMetaData.CreateFkConstraint(List1 fieldPairs, MultiValueDictionary2 modelBasedForeignKeyConstraints, Boolean forModelOnlyRelationship) at SD.LLBLGen.Pro.ApplicationCore.MetaData.MetaDataStore.CreateFkConstraintForDatabase(String driverID, List1 fieldPairs, MultiValueDictionary2 modelBasedForeignKeyConstraints, Boolean forModelOnlyRelationship) at SD.LLBLGen.Pro.ApplicationCore.ProjectClasses.Project.ProduceFkConstraintsForInheritanceEdge(InheritanceEdge edge, MultiValueDictionary2 modelBasedForeignKeyConstraints) at SD.LLBLGen.Pro.ApplicationCore.ProjectClasses.Project.ProduceFkConstraintsForInheritanceEdges(MultiValueDictionary2 modelBasedForeignKeyConstraints) at SD.LLBLGen.Pro.ApplicationCore.ProjectClasses.Project.RunValidationAndMetaDataAdjustProcess(Boolean validationOnly) at SD.LLBLGen.Pro.ApplicationCore.ProjectClasses.Project.ValidateAndOptionallyAdjustMetaData(Boolean validationOnly) at SD.LLBLGen.Pro.Gui.Classes.GuiController.<>c__DisplayClassde.<PerformProjectValidationAndOptionallyMetaDataAdjustmentAction>b__d9() at SD.Tools.Algorithmia.Commands.Command`1.Do() in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\Commands\Command.cs:line 178 at SD.Tools.Algorithmia.Commands.CommandQueue.PerformDoRedoCommand(Boolean performRedo) in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\Commands\CommandQueue.cs:line 151 at SD.Tools.Algorithmia.Commands.CommandQueue.DoCurrentCommand() in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\Commands\CommandQueue.cs:line 127 at SD.Tools.Algorithmia.Commands.CommandQueueManager.EnqueueAndRunCommand(CommandBase toEnqueueAndRun) in C:\Myprojects\VS.NET Projects\Algorithmia_hg\SD.Tools.Algorithmia\Commands\CommandQueueManager.cs:line 394 at SD.LLBLGen.Pro.Gui.Classes.GuiController.PerformProjectValidationAndOptionallyMetaDataAdjustmentAction(Boolean validationOnly, Boolean showMessageBoxOnZeroErrors) at SD.LLBLGen.Pro.Gui.Classes.GuiController.PerformGenerateSourceCodeAction() at SD.LLBLGen.Pro.Gui.Forms.MainWindow.HandleMainMenuCommand(CommandEventArgs e) at SD.LLBLGen.Pro.Gui.Forms.MainWindow._mainMenu_CommandClick(Object sender, CommandEventArgs e) at Janus.Windows.UI.CommandBars.UICommandManager.OnCommandClick(CommandEventArgs e) at Janus.Windows.UI.CommandBars.UICommandManager.Janus.Windows.UI.CommandBars.ICommandOwner.OnCommandClicked(CommandEventArgs e) at Janus.Windows.UI.CommandBars.UICommandCollection.c(Object , CommandEventArgs ) at Janus.Windows.UI.CommandBars.UICommand.OnClick(CommandEventArgs e) at Janus.Windows.UI.CommandBars.UICommand.ar() at Janus.Windows.UI.Internal.JNSCZ.OnMouseUp(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at Janus.Windows.UI.Internal.JNSCZ.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Dec-2012 06:00:21   

You are using an old build. Still, I can reproduce it with the latest build (March 12th, 2012). I think the reason is this:

<EntityMapping EntityName=":EventPaymentPlanDeposit" TargetName="bangfaceweekender:dbo:tbl_event_payment_plan_deposit">
         <FieldMappings>
             ...
            <FieldMapping FieldName="DepositPercentage" TargetFieldName="DepositPercentage" />
            <FieldMapping FieldName="EventId" TargetFieldName="EventId" />
            <FieldMapping FieldName="PaymentPlanId" TargetFieldName="EventId" />

For EventPaymentPlanDeposit.PaymentPlanId the target field is EventId, which is wrong. So open that entity and fix the mapping (map it to the PaymentPlanId element).

I don't know how you ended up with this wrong mapping, but fixing it makes the exception disappear.

David Elizondo | LLBLGen Support Team
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 18-Dec-2012 13:19:28   

It seems to do it when creating the hierarchy.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Dec-2012 16:26:27   

Ian wrote:

It seems to do it when creating the hierarchy.

If I destroy the hierarchy and then make EventPaymentPlanDeposit entity a subtype of EventPaymentPlan, the mappings are created correctly and the "Validation of the model and mappings" passes.

Could you please try with the latest v3.1 build?

David Elizondo | LLBLGen Support Team