one database, why the generated codes from 2 LLBLGen Pro projects are not the same

Posts   
 
    
lss
User
Posts: 25
Joined: 23-Dec-2008
# Posted on: 29-Aug-2009 00:03:51   

Hello,

I have a production project running, now I try to create a testing project on my local computer.

I have to create a new LLBLGen Pro from scratch because we don't know where original LLBLGen project is stored. I'm using the same data base for the new LLBLGen Pro project. After the codes are generated, I encountered 2 obvious problems:

  1. Some names in the new generated codes are changed, so the ASP codes would not work, unless I modify them (of course)

CS0117: 'App2.DAL.EntityClasses.ListBranchEntity' does not contain a definition for 'BranchStateTax'

Once I changed 'BranchStateTax' to BranchTaxStae, the problem is solved.

  1. The new generated codes are not consistant with the old generated code eventhough the name of the entities are the same.

        /// <summary> Gets the value of the related field this.ListIndustrialSkillCategories.Category.</summary>
        public virtual System.String Category
        {
            get
            {
                ListIndustrialSkillCategoriesEntity relatedEntity = this.ListIndustrialSkillCategories;
                if(relatedEntity!=null)
                {
                    return relatedEntity.Category;
                }
                else
                {
                    return (System.String)TypeDefaultValue.GetDefaultValue(typeof(System.String));
                }
            }

        }   

The old code has this particular part but not in the new code. So that I got the following error message:

CS0117: 'App2.DAL.EntityClasses.ListIndustrialSkillsEntity' does not contain a definition for 'Category'

Would you please explain why the codes from the same database are not the same. Why some parts of the code are missing. And what is the best way to fix the problems.

Database: SQL Server 2005 LLBL Gen Pro: 1.0.2005.1 Language: C#

Thank you, lss

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Aug-2009 04:11:29   

Hi Iss,

Having two generated code projects from the same DB doesn't mean it should be equivalent. As yo can do a lot of mapping changes in LLBLGen Designer. For instance, change the field names, field mapped on relations, hide fields, entity inheritance, map a view as an entity, etc.

So, depending on that changes, create an equivalent .lgp project would be easy or hard. So you have to approaches:

A. Make the new LLBLGen project match your existing generated DAL code. B. Generate a new DAL and make your application match with this new generated code.

I guess you would prefer approach A. So, you have to do a try-error process to make this up.

If you receive errors like "ListBranchEntity : does not contain a definition for 'BranchStateTax'", it means that a field/field-on-relation was renamed. So you have to go in your LLBLGen project (.lgp) and change the field name. In this case, go to ListBranchEntity and change the field name (from "the actual name" to "BranchStateTax").

Tip: look on the old generated code. Find \FactoryClasses\EntityFieldFactory.cs. There you can find the old field mappings (the db name and the actual field name). That would give you a quickest hint about what entities/field names were changed.

David Elizondo | LLBLGen Support Team
rdhatch
User
Posts: 198
Joined: 03-Nov-2007
# Posted on: 29-Aug-2009 04:40:08   

Hi lss -

Where in Wisconsin are you? I'm in Green Bay.

Ryan

lss
User
Posts: 25
Joined: 23-Dec-2008
# Posted on: 31-Aug-2009 15:51:23   

Thank you David,

How about for question 2 that part of the generated code is missing in the new code. How to make this appear in the new generated code.??

Code:

    /// <summary> Gets the value of the related field this.ListIndustrialSkillCategories.Category.</summary>
    public virtual System.String Category
    {
        get
        {
            ListIndustrialSkillCategoriesEntity relatedEntity = this.ListIndustrialSkillCategories;
            if(relatedEntity!=null)
            {
                return relatedEntity.Category;
            }
            else
            {
                return (System.String)TypeDefaultValue.GetDefaultValue(typeof(System.String));
            }
        }

    }   

lss

lss
User
Posts: 25
Joined: 23-Dec-2008
# Posted on: 31-Aug-2009 15:52:02   

Ryan,

I'm in Madison.

lss

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 31-Aug-2009 16:03:57   

How about for question 2 that part of the generated code is missing in the new code. How to make this appear in the new generated code.??

Code:

    /// <summary> Gets the value of the related field this.ListIndustrialSkillCategories.Category.</summary>
    public virtual System.String Category
    {
        get
        {
            ListIndustrialSkillCategoriesEntity relatedEntity = this.ListIndustrialSkillCategories;
            if(relatedEntity!=null)
            {
                return relatedEntity.Category;
            }
            else
            {
                return (System.String)TypeDefaultValue.GetDefaultValue(typeof(System.String));
            }
        }

    }   

This looks like a field mapped on a related field. So in this project you have the field Category from ListIndustrialSkillCategories mapped as Category on the entity in-which you have the above code. This can be set in the entity's Edit/Properties window, in the "Fields on related fields" sub-Tab.

lss
User
Posts: 25
Joined: 23-Dec-2008
# Posted on: 31-Aug-2009 17:06:15   

Walaa,

thanks you.

lss