Exception Generating With Manager Template

Posts   
 
    
taylor74
User
Posts: 59
Joined: 06-Oct-2004
# Posted on: 05-Jan-2005 01:50:27   

I'm wanting to generate some code with the Managers custom template, but I'm running into an exception. Being new to LLBL and not into the advanced stuff yet, I'm not sure where to begin to look.

Here's the exception I get when trying to generate code.

Item has already been added. Key in dictionary: "Bagged - SeedInventoryConditionPlant (m:1)" Key being added: "Bagged - SeedInventoryConditionPlant (m:1)"

FYI, the relation mentioned in the exception uses a composite primary key.

And here is the stack trace.

-----[Core exception]-------------------- at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at System.Collections.Hashtable.Add(Object key, Object value) at EntityManagerBaseTemplate.GetWritableFieldRelationPairs(EntityDefinition entity) at EntityManagerBaseTemplate.__ScriptCode() at EntityManagerBaseTemplate.___RUN(IGenerator executingGenerator, Hashtable parameters, StreamWriter outputWriter, Object activeObject) at SD.LLBLGen.Pro.LptParser.DotNetTemplateEngine.Perform(IGenerator executingGenerator, ITask taskDefinition, Hashtable parameters) at SD.LLBLGen.Pro.GeneratorCore.Task.Perform(IGenerator executingGenerator) at SD.LLBLGen.Pro.GeneratorCore.TaskGroup.Perform(IGenerator executingGenerator) at SD.LLBLGen.Pro.GeneratorCore.TaskGroup.Perform(IGenerator executingGenerator) at SD.LLBLGen.Pro.GeneratorCore.Generator.Start(ITaskGroup tasksToExecute, Project projectDefinition, TemplateSetDefinition templateSet, ApplicationConfiguration configurationSettings) at SD.LLBLGen.Pro.Gui.Forms.MainWindow.StartGeneratorProcess()

Any thoughts?

cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 05-Jan-2005 03:16:47   

Did you grab the templates from the Subversion repository or my website?

That will help narrow it down a bit.

taylor74
User
Posts: 59
Joined: 06-Oct-2004
# Posted on: 05-Jan-2005 03:56:14   

I got them from the Subversion repository just a couple days ago.

Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 05-Jan-2005 13:38:00   

taylor74 wrote:

Any thoughts?

Thats a bug in my code... I will take a look.

Marcus

Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 05-Jan-2005 13:40:15   

Can you send an SQL Create Scripts which includes the tables on both sides of the relation.

taylor74
User
Posts: 59
Joined: 06-Oct-2004
# Posted on: 05-Jan-2005 16:47:52   

CREATE TABLE [dbo].[Bagged] ( [BaggedID] [int] IDENTITY (1, 1) NOT NULL , [YearID] [int] NOT NULL , [Lot] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [Units] [int] NOT NULL , [BaggedDate] [datetime] NULL , [Notes] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO

CREATE TABLE [dbo].[SeedInventoryConditionPlant] ( [YearID] [int] NOT NULL , [Lot] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [Reference] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [SeedID] [int] NOT NULL , [UnitTypeID] [int] NOT NULL , [DeliveryGroupID] [int] NULL ) ON [PRIMARY] GO

ALTER TABLE [dbo].[Bagged] ADD CONSTRAINT [PK_Bagged] PRIMARY KEY CLUSTERED ( [BaggedID] ) ON [PRIMARY] GO

ALTER TABLE [dbo].[SeedInventoryConditionPlant] ADD CONSTRAINT [PK_SeedInventoryConditionPlant] PRIMARY KEY CLUSTERED ( [YearID], [Lot] ) ON [PRIMARY] GO

ALTER TABLE [dbo].[Bagged] ADD CONSTRAINT [FK_Bagged_SeedInventoryConditionPlant] FOREIGN KEY ( [YearID], [Lot] ) REFERENCES [dbo].[SeedInventoryConditionPlant] ( [YearID], [Lot] ) ON DELETE CASCADE ON UPDATE CASCADE GO

Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 05-Jan-2005 18:07:56   

I was able to reproduce the problem for composite primary keys (which are not supported for Create methods) here and have fixed it. simple_smile

The fix has been checked into SubVersion.

taylor74
User
Posts: 59
Joined: 06-Oct-2004
# Posted on: 05-Jan-2005 18:29:20   

Thanks for the update. That did the trick. smile