one-to-many relation does not mapp correctly between 3 class library

Thread is closed for posting
3 posts, 0 answers
  1. amir sherafatian
    amir sherafatian avatar
    42 posts
    Member since:
    Aug 2009

    Posted 24 Jun 2010 Link to this post

    hi ;
    i have 3 class library with these names : 1-DC , 2-FrameWork ,  3-PCI
    and i need to generate 2 one to many relation between three classes of these classlibraries by forward mapping but i have a problem;

    my classes are :

    this UML Model is what i need :
    DC::DCDocument ---------> FrameWork::WFTemplateNode <-------- PCI::PCISourceObservation

    and for this purpose i created two collection fields Like Below :

    public class DCDocument
        private IList<WFTemplateNode> FTemplateNodes;

    public class PCI::PCISourceObservation
            private IList<WFTemplateNode> FPhaseAdmins;

    and i`m sure that i mapped correctly these filed.
    for mapping these collection i only unchcked the "join table" and checked the "cascade delete" option from forward mapping wizard

    i mapped all collection filed which i used so far , with this approach that i mentioned above line and does not have any problem.
    but in this case , after i built the solution, last classlibrary which have been built , covered and override the previous class library mapping that have been built early, and only generate one foreign key field in WFTemplateNode Table ,
    foreign key from DCDocument OR foreign key from PCISourceObservation

    thats urgent
    help me please
  2. amir sherafatian
    amir sherafatian avatar
    42 posts
    Member since:
    Aug 2009

    Posted 27 Jun 2010 Link to this post

    may you help me
  3. Serge
    Serge avatar
    375 posts

    Posted 28 Jun 2010 Link to this post

    Hello amir sherafatian,

     There is a solution to your problem but you should note that this is expected behaviour. The tool that modifies the database schema is usually run on one class library, this means that the UpgradeDatabase property on the project is only set to true in one of the projects. I suspect that this is not the case in your solution, and you have this option set to true to all of your projects. 

    This means that when the specified project has finished building, the schema tool is run and it modifies the database schema.  In order however to upgrade correctly the schema tool has to know of which assemblies the model is consisted. This happens through the app.config file. In it there is an openaccess section that has an references child node. You can find more information on this in this help article.

    So what you need to do is to create this <references> section in the app.config of one of the class libraries which references the other two. Then you should set the UpgradeDatabase of the referenced projects to false and only set it to true in this class library project.

    When you then build the chosen Class Library project, your database will be correctly updated.

    I do hope this helps. If you need more information please contact us back.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top