CodeSmith Community
Your Code. Your Way. Faster!

Template fails to handle more then one foreign key in a table

Latest post 12-29-2006 1:21 PM by deitysteve. 3 replies.
  • 11-09-2006 4:47 AM

    • Tanno
    • Top 100 Contributor
    • Joined on 10-06-2006
    • Posts 50
    • Points 1,215

    Template fails to handle more then one foreign key in a table

    Hi All,

    Using version 2.0.1.430, I see that the first field with a foreign key is handled correctly and the second field with a foreign key is somehow skipped completely. The field does not appear in the <Entity> Edit page.

    regards  

     Tanno

      

     

    Filed under:
    • Post Points: 35
  • 11-10-2006 10:13 AM In reply to

    Re: Template fails to handle more then one foreign key in a table

    Can you post an example table script so we can try and recreate the issue?

    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 35
  • 11-14-2006 5:51 AM In reply to

    • Tanno
    • Top 100 Contributor
    • Joined on 10-06-2006
    • Posts 50
    • Points 1,215

    Re: Template fails to handle more then one foreign key in a table

    Sure,

    The script for the table and foreign keys follow below.

    The foreign key field that is not handled by .netTiers is the one on the field UserID with fieldtype UniqueIdentifier that references the AspNet_Users table. (The AspNet tables have been automatically created in the same database, but I include here the create script)

     CREATE TABLE dbo.Contactpersoon(
            ContactpersoonID Int IDENTITY NOT NULL,
            Achternaam VarChar(32) NOT NULL,
            Voornaam VarChar(32) NOT NULL,
            BedrijfID Int NOT NULL,
            UserID UniqueIdentifier NOT NULL,
            Titel VarChar(8) NULL,
            Functie VarChar(32) NOT NULL,
            Afdeling VarChar(32) NOT NULL,
            Telefoonnr VarChar(16) NOT NULL,
            Mobielnr VarChar(16) NULL,
            Faxnr VarChar(16) NULL,
        CONSTRAINT P_Contactpersoon PRIMARY KEY CLUSTERED (
          ContactpersoonID
        ),
        CONSTRAINT U_Contactpersoon UNIQUE NONCLUSTERED (
          UserID
        )
    ) ON "PRIMARY"
    GO

    ALTER TABLE dbo.ContactPersoon WITH NOCHECK ADD CONSTRAINT F_ContactPersoon_UserID FOREIGN KEY (UserID)
      REFERENCES dbo.ASPNET_USERS (UserID)
       ON DELETE CASCADE
       ON UPDATE CASCADE
    GO

    ALTER TABLE dbo.ContactPersoon WITH NOCHECK ADD CONSTRAINT F_ContactPersoon_BedrijfID FOREIGN KEY (BedrijfID)
      REFERENCES dbo.Bedrijf (BedrijfID)
       ON DELETE CASCADE
       ON UPDATE CASCADE
    GO

    CREATE TABLE dbo.Bedrijf (
        BedrijfID Int IDENTITY NOT NULL,
        BedrijfsNaam VarChar(32) NOT NULL,
        KVK_nr VarChar(16) NOT NULL,
        BTW_nr VarChar(16) NOT NULL,
        Subnaam VarChar(32),
        Telefoonnr VarChar(16) NOT NULL,
        Faxnummer VarChar(16),
        CONSTRAINT P_Bedrijf PRIMARY KEY CLUSTERED (
          BedrijfID
        ),
        CONSTRAINT U_Bedrijf1 UNIQUE NONCLUSTERED (
          KVK_nr
        ),
        CONSTRAINT U_Bedrijf2 UNIQUE NONCLUSTERED (
          Btw_nr
        )
    ) ON "PRIMARY"
    GO

    CREATE TABLE dbo.aspnet_Users (
        ApplicationId Uniqueidentifier NOT NULL,
        UserId Uniqueidentifier DEFAULT newid() NOT NULL,
        UserName NVarChar(256) NOT NULL,
        LoweredUserName NVarChar(256) NOT NULL,
        MobileAlias NVarChar(16) DEFAULT NULL,
        IsAnonymous Bit DEFAULT (0) NOT NULL,
        LastActivityDate DateTime NOT NULL,
        CONSTRAINT PK__aspnet_Users__03317E3D PRIMARY KEY NONCLUSTERED (
          UserId
        )
    ) ON "PRIMARY"
    GO

    Filed under:
    • Post Points: 35
  • 12-29-2006 1:21 PM In reply to

    Re: Template fails to handle more then one foreign key in a table

    Robert,

    Is there (or will there be) any resolution to this issue?

    Thanks!

    • Post Points: 5
Page 1 of 1 (4 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems