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

Model-First - Many-to-many relationships w/ additional fields

3 Answers 58 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hunter
Top achievements
Rank 1
Hunter asked on 01 Aug 2013, 03:43 AM
Could someone please tell me the difference between the following two documents:
Using Custom Join Table
Without a Join Table

Almost all of my join tables will have additional properties. I am assuming I will not be using this method much: Using Default Join Table
I just want to make sure I am on the right track by creating my own join tables using the above 2 methods. I just don't know the difference between them. They seem the same to me.

3 Answers, 1 is accepted

Sort by
0
Accepted
Kristian Nikolov
Telerik team
answered on 01 Aug 2013, 03:46 PM
Hi Hunter,

While both approaches result in a many to many association, there is a very important difference between them and depending on your scenario, you may prefer one over the other.

In the Custom Join Table approach you create the join table using the Table Editor. Although you can customize the join table by adding additional columns, you will not be able to execute queries against it in your project because there is no entity mapped to it.

The Without a Join Table article has a bit misleading name, because in the end you still get a join table. With this approach however, your join table is mapped to an entity (CustomerOrder) and that means you can query it from your OpenAccess context.

I hope this information was helpful to you. In case you have additional questions, do not hesitate to get back to us.

Regards,
Kristian Nikolov
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
0
Hunter
Top achievements
Rank 1
answered on 02 Aug 2013, 01:02 AM
Very good response. Now I understand. When would be a good time to use the automated default join approach?
0
Kristian Nikolov
Telerik team
answered on 02 Aug 2013, 01:39 PM
Hi Hunter,

The Default Join Table approach is useful when you need to quickly create many to many association between entities and no customization is needed. This method is easy, but does not offer much control and thus is preferred in simple scenarios.

As you have already noticed, m:n association based on a default join table is not registered as a schema change when migrating your database. This behavior is expected and the reason for it is that when creating the association, the default join table is not added to the model metadata - no additional table can be seen in the Model Schema Explorer. Thus when migrating, there are no differences between the model and database schemata.
If you have a scenario where you need to update your database with m:n association from your Domain Model (in a Model First approach), you will need to use either Custom Join Table or the so called Without a Join Table approach.

If you have further inquiries do not hesitate to contact us again.

Regards,
Kristian Nikolov
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Tags
General Discussions
Asked by
Hunter
Top achievements
Rank 1
Answers by
Kristian Nikolov
Telerik team
Hunter
Top achievements
Rank 1
Share this question
or