in

CodeSmith Community

Your Code. Your Way. Faster!

Build Errors in VS After Generation

Last post 10-08-2007 10:00 AM by hepieter. 23 replies.
Page 1 of 2 (24 items) 1 2 Next >
Sort Posts: Previous Next
  • 03-30-2007 1:10 PM

    • schleppo
    • Top 500 Contributor
    • Joined on 03-20-2007
    • Posts 10
    • Points 200

    Build Errors in VS After Generation

    After I generate the various layers and open the solution in VS 2005, I get multiple hundred build errors like the following:

    "[namespace].Entities.[tablename] does not contain a definition for [fieldname]Source"

    It seems to be related to a certain subset of tables (not all of them), but I can't determine what is causing the inaccurate generation of the definitions in the Entities project.  Any thoughts?

    • Post Points: 35
  • 04-02-2007 2:09 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 921
    • Points 34,675

    Re: Build Errors in VS After Generation

    The [fieldname]Source properties are generated for FK relations - make sure you include al tables that are used in relations in your generation.

    hth

    swin 

    -------------------------------------------------
    Member of the .NetTiers team
    -------------------------------------------------
    • Post Points: 35
  • 04-02-2007 9:21 AM In reply to

    • schleppo
    • Top 500 Contributor
    • Joined on 03-20-2007
    • Posts 10
    • Points 200

    Re: Build Errors in VS After Generation

    All tables are being included.
    • Post Points: 5
  • 04-09-2007 9:15 AM In reply to

    • schleppo
    • Top 500 Contributor
    • Joined on 03-20-2007
    • Posts 10
    • Points 200

    Re: Build Errors in VS After Generation

    *Bump*
    • Post Points: 5
  • 05-14-2007 10:29 AM In reply to

    • schleppo
    • Top 500 Contributor
    • Joined on 03-20-2007
    • Posts 10
    • Points 200

    Re: Build Errors in VS After Generation

    *Bump*
    • Post Points: 35
  • 05-14-2007 1:31 PM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 921
    • Points 34,675

    Re: Build Errors in VS After Generation

    Can you provide an sql script so we can try to replicate the problem - include all related tables and relations etc.

    swin

    -------------------------------------------------
    Member of the .NetTiers team
    -------------------------------------------------
    • Post Points: 35
  • 05-14-2007 4:16 PM In reply to

    • schleppo
    • Top 500 Contributor
    • Joined on 03-20-2007
    • Posts 10
    • Points 200

    Re: Build Errors in VS After Generation

    Ok, I've done some experimenting to narrow down the problem.  Here are 3 tables I created to illustrate my problem:

    -->

    CREATE TABLE [dbo].[Customers](
        [CustomerID] [int] NOT NULL,
        [CustomerTypeID] [int] NOT NULL,
        [CustomerName] [nvarchar](50) NULL,
     CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED
    (
        [CustomerID] ASC,
        [CustomerTypeID] ASC
    )
    ) ON [PRIMARY]

     
    CREATE TABLE [dbo].[Orders](
        [OrderID] [int] NOT NULL,
        [OrderName] [nvarchar](50) NULL,
     CONSTRAINT [PK_Orders] PRIMARY KEY CLUSTERED
    (
        [OrderID] ASC
    )
    ) ON [PRIMARY]

     
    CREATE TABLE [dbo].[CustomerOrders](
        [CustomerID] [int] NOT NULL,
        [CustomerTypeID] [int] NOT NULL,
        [OrderID] [int] NOT NULL,
     CONSTRAINT [PK_CustomerOrders] PRIMARY KEY CLUSTERED
    (
        [CustomerID] ASC,
        [CustomerTypeID] ASC,
        [OrderID] ASC
    )
    ) ON [PRIMARY]

    ALTER TABLE [dbo].[CustomerOrders]  WITH CHECK ADD  CONSTRAINT [FK_CustomerOrders_Customers] FOREIGN KEY([CustomerID], [CustomerTypeID])
    REFERENCES [dbo].[Customers] ([CustomerID], [CustomerTypeID])

    ALTER TABLE [dbo].[CustomerOrders]  WITH CHECK ADD  CONSTRAINT [FK_CustomerOrders_Orders] FOREIGN KEY([OrderID])
    REFERENCES [dbo].[Orders] ([OrderID])

    <--

    The problem seems to be related to using the composite primary key from the Customers table (CustomerID and CustomerTypeID) as part of the foreign key in the CustomerOrders table.  If I remove CustomerTypeID from the Customers and CustomerOrders tables, the project .netTiers generates using these three tables builds correctly.  When the composite primary key is present, I get the previously referenced error when building the generated project:

    • Error    2    'Test.Entities.CustomerOrders' does not contain a definition for 'CustomerIDSource'    D:\Development\DotNET\Test\Test.Data\Bases\OrdersProviderBaseCore.generated.cs    496    33    Test.Data

    • Error    3    'Test.Entities.CustomerOrders' does not contain a definition for 'CustomerTypeIDSource'    D:\Development\DotNET\Test\Test.Data\Bases\OrdersProviderBaseCore.generated.cs    499    16    Test.Data

    • Error    5    'Test.Entities.CustomerOrders' does not contain a definition for 'CustomerTypeIDSource'    D:\Development\DotNET\Test\Test.Data\Bases\CustomersProviderBaseCore.generated.cs    504    16    Test.Data

    I found a topic from 2005 that seemed to be the same problem. (http://community.codesmithtools.com/forums/thread/9214.aspx).  Thanks for your help.

     

     

    • Post Points: 35
  • 05-15-2007 1:06 PM In reply to

    • schleppo
    • Top 500 Contributor
    • Joined on 03-20-2007
    • Posts 10
    • Points 200

    Re: Build Errors in VS After Generation

    Anyone?
    • Post Points: 5
  • 05-16-2007 8:40 AM In reply to

    • schleppo
    • Top 500 Contributor
    • Joined on 03-20-2007
    • Posts 10
    • Points 200

    Re: Build Errors in VS After Generation

    Bump.
    • Post Points: 5
  • 05-18-2007 9:33 AM In reply to

    Re: Build Errors in VS After Generation

    Hi:

    I am having the exact same problem. I have some table relations very similar to your example and have the same compile problems.

    I narrowed the source from this a little more and found something (Generating the solution project for the above db struct using nettiers rev 563 from svn trunk):

    The class CustomerOrdersBase (from TestM2M.Entities\CustomerOrdersBase.generated.cs) have the following Source Fields (I am removing the xml comments for readability):

            public virtual Customers CustomerIDCustomerTypeIDSource
              {
                get { return entityData.CustomerIDCustomerTypeIDSource; }
                set { entityData.CustomerIDCustomerTypeIDSource = value; }
              }

            public virtual Orders OrderIDSource
              {
                get { return entityData.OrderIDSource; }
                set { entityData.OrderIDSource = value; }
              }


    But the related OrdersProviderBaseCore class (from TestM2M.Data\Bases\OrdersProviderBaseCore.generated.cs) is trying to access those fields using the following code (DeepSave Method, line 483):

                        foreach(CustomerOrders child in entity.CustomerOrdersCollection)
                        {
                            if(child.OrderIDSource != null)
                                child.OrderID = child.OrderIDSource.OrderID;
                            else
                                child.OrderID = entity.OrderID;

                            //Handle right table of CustomersCollection_From_CustomerOrders
                            if(child.CustomerIDSource != null)
                                child.CustomerID = child.CustomerIDSource.CustomerID;

                            //Handle right table of CustomersCollection_From_CustomerOrders
                            if(child.CustomerTypeIDSource != null)
                                child.CustomerTypeID = child.CustomerTypeIDSource.CustomerTypeID;
                        }
     

     As you can see, nettiers is generating the above code referencing each source property of the CustomerOrdersBase class as individual properties instead of using CustomerIDCustomerTypeIDSource.

    Same thing happens on the other relation endpoint in TestM2M.Data\Bases\CustomersProviderBaseCore.generated.cs (DeepSave method, line 499)

    I dont know wich one is wrong as I am really new using nettiers, but looks like there is some mismatch when generating / using the Source properties from a M2M relation with multiple foreign keys as in this example.

    I modified the generated code of the OrdersProviderBaseCore class to this:

                            //Handle right table of CustomersCollection_From_CustomerOrders
                            if(child.CustomerIDCustomerTypeIDSource != null)
                                child.CustomerID = child.CustomerIDCustomerTypeIDSource.CustomerID;

                            //Handle right table of CustomersCollection_From_CustomerOrders
                            if(child.CustomerIDCustomerTypeIDSource != null)
                                child.CustomerTypeID = child.CustomerIDCustomerTypeIDSource.CustomerTypeID;
     

    And made a similar change to CustomersProviderBaseCore and now it compiles, but well, I dont know if this is the correct approach or the CustomerOrders class should be the one to be changed. I will run some Unit Tests on it and check to see if i find some problems with this change, but well, if any of the nettiers dev members can check this it will be nice. :D

    I hope this help.

    Best regards and sorry for my bad english. :(

     

    Best regards,

    Nosferatus
    Filed under: ,
    • Post Points: 35
  • 05-22-2007 8:02 AM In reply to

    • schleppo
    • Top 500 Contributor
    • Joined on 03-20-2007
    • Posts 10
    • Points 200

    Re: Build Errors in VS After Generation

    Thanks for your input, nosferatus.  At least I'm not the only one having the issue.  Hopefully someone from .netTiers can give us some feedback as to what may be the cause.  By the way, your English is fine.  Smile
    • Post Points: 35
  • 05-22-2007 3:08 PM In reply to

    Re: Build Errors in VS After Generation

    I imagine it has something to do with the way your composite primary keys are being setup.  We'll dig into this one.

    Robert Hinojosa

    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams

    http://www.nettiers.com
    -------------------------------------
    • Post Points: 65
  • 05-24-2007 3:10 PM In reply to

    • tmy13
    • Not Ranked
    • Joined on 05-24-2007
    • Posts 1
    • Points 5

    Re: Build Errors in VS After Generation

    Any idea when a fix will be available for this issue?
    • Post Points: 5
  • 05-29-2007 3:12 PM In reply to

    Re: Build Errors in VS After Generation

    Hi all:

    After a couple of days investigating this issue I made a patch wich I think is correctly solving it. I am not sure if the solution has the correct approach or elegance but well, at least for me it is working with several dbs including the test case db from schleppo and my private db.

    Can you guys test it and check if it works with yours too?? And maybe a netiers dev can review it to check if I made any mistake ?? :D

     
    Well, I hope this helps, just my 2 cents,

     
    Nosferatus.

    Best regards,

    Nosferatus
    • Post Points: 95
  • 05-29-2007 6:31 PM In reply to

    • asmussen
    • Top 200 Contributor
    • Joined on 11-12-2006
    • Posts 21
    • Points 675

    Re: Build Errors in VS After Generation

    Is that an "official fix".

    I am not sure if my problem is related thus not sure if I need the fix.

    My post is here: http://community.codesmithtools.com/forums/thread/24823.aspx 

    • Post Points: 35
Page 1 of 2 (24 items) 1 2 Next >
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems