Error: The type 'BaiParserDal.RelationClasses.ProcessMonitorDtlRelations' already contains a definition for 'ProcessMonitorEntityUsingProcessMonitorId'

Posts   
 
    
john222
User
Posts: 2
Joined: 03-Oct-2013
# Posted on: 03-Oct-2013 03:42:01   

First - many thanks to anyone who can point me in the right direction!

I'm running LLBLGen Pro 4.0 Final and I'm getting the error message below.

The type 'BaiParserDal.RelationClasses.ProcessMonitorDtlRelations' already contains a definition for 'ProcessMonitorEntityUsingProcessMonitorId'

--

I diff'ed the 2 code clips and they are identical - except for the var named ProcessMonitor_ in the following line:

IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "ProcessMonitor_", false);

--

Here are both code clips. One follows the other as you can tell in the attached file.

    /// <summary>Returns a new IEntityRelation object, between ProcessMonitorDtlEntity and ProcessMonitorEntity over the m:1 relation they have, using the relation between the fields:
    /// ProcessMonitorDtl.ProcessMonitorId - ProcessMonitor.ProcessMonitorId
    /// </summary>
    public virtual IEntityRelation ProcessMonitorEntityUsingProcessMonitorId
    {
        get
        {
            IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "ProcessMonitor", false);
            relation.AddEntityFieldPair(ProcessMonitorFields.ProcessMonitorId, ProcessMonitorDtlFields.ProcessMonitorId);
            relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ProcessMonitorEntity", false);
            relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ProcessMonitorDtlEntity", true);
            return relation;
        }
    }


    /// <summary>Returns a new IEntityRelation object, between ProcessMonitorDtlEntity and ProcessMonitorEntity over the m:1 relation they have, using the relation between the fields:
    /// ProcessMonitorDtl.ProcessMonitorId - ProcessMonitor.ProcessMonitorId
    /// </summary>
    public virtual IEntityRelation ProcessMonitorEntityUsingProcessMonitorId
    {
        get
        {
            IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "ProcessMonitor_", false);
            relation.AddEntityFieldPair(ProcessMonitorFields.ProcessMonitorId, ProcessMonitorDtlFields.ProcessMonitorId);
            relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ProcessMonitorEntity", false);
            relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ProcessMonitorDtlEntity", true);
            return relation;
        }
    }
Attachments
Filename File size Added on Approval
ProcessMonitorDtlRelations.cs 4,399 03-Oct-2013 03:42.47 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Oct-2013 07:57:42   

This look like you have a duplicate relation: two relations from the same FK field pointing to the same PK. Please go to your LLBLGen Project file and delete the duplicate relation from the FK entity and then re-generate the code.

If the problem persists, please post your .llblgenproj file (if you prefer, you can do that in a new HelpDesk thread, which is private).

David Elizondo | LLBLGen Support Team
john222
User
Posts: 2
Joined: 03-Oct-2013
# Posted on: 03-Oct-2013 14:37:23   

Thank you so much for the quick response!

You are exactly correct and once I removed one of the duplicate constraints LLBLGen generates and compiles with no problems.

The original author had a constraint and then I added a cascading delete constraint without removing the original constraint. Both are posted below.

--

original:

ALTER TABLE [DataBroker].[ProcessMonitorDtls] WITH NOCHECK ADD CONSTRAINT [fkProcessMonitorDtls_ProcessMonitor] FOREIGN KEY([ProcessMonitorID]) REFERENCES [DataBroker].[ProcessMonitor] ([ProcessMonitorID]) GO

--

my duplicate:

ALTER TABLE [DataBroker].[ProcessMonitorDtls] WITH NOCHECK ADD CONSTRAINT [FK_ProcessMonitorDtls_Delete_Cascade] FOREIGN KEY([ProcessMonitorID]) REFERENCES [DataBroker].[ProcessMonitor] ([ProcessMonitorID]) ON DELETE CASCADE GO