This is a migrated thread and some comments may be shown as answers.

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

2 Answers 35 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
amir sherafatian
Top achievements
Rank 1
amir sherafatian asked on 24 Jun 2010, 08:24 AM
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 :
DC::DCDocument
FrameWork::WFTemplateNode
PCI::PCISourceObservation

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 Answers, 1 is accepted

Sort by
0
amir sherafatian
Top achievements
Rank 1
answered on 27 Jun 2010, 05:46 AM
may u help me
0
Serge
Telerik team
answered on 28 Jun 2010, 05:53 PM
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.

All the best,
Serge
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
Tags
Databases and Data Types
Asked by
amir sherafatian
Top achievements
Rank 1
Answers by
amir sherafatian
Top achievements
Rank 1
Serge
Telerik team
Share this question
or