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

Associations to entities in a separate designer

3 Answers 58 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ron
Top achievements
Rank 1
Ron asked on 04 May 2011, 07:37 AM
Trying to figure out if your product allows developers to break the object model up into more workable chunks rather than have the entire thing in one rlinq file. Entity Framework doesn't let you do it so looking at alternatives. Is it possible to create an association from an entity in one designer to an entity in another one? The toolbox option doesn't let you do it. I can't type anything into the Navigation section of an entity manually it doesn't appear. The .cs file says it'll be regenerated on changes as one would expect. Is there somewhere else we can try?

Thank you,
Ron

3 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 05 May 2011, 04:11 PM
Hi Ron,

You will be able to merge two or more models into one, however, this will require some manual steps to be performed. I have attached a demo project which you can use for reference. Here are the details how I created it:
1. Create a project and add the two domain models. While adding the models, on the last page of the wizard disable the Generate context option, the context has to be created manually.
Note that a model should not contain any tables included in another model.
2. Create a class deriving from OpenAccessContext (in the example this is MergedContext). The class content is very similar to the one you would get automatically generated. However, here you need to implement a method like the GetMetadataSource which merges the metadata from the two models into one. Once you have the method, initialize the static metadataSource variable with it.
3. (Optional) For each class from the two models create an IQueryable<T> endpoint which can be used in linq queries. This step is optional because you can use the GetAll<T> method directly as well.

This is everything to get the models merged, now you can work with any class from a single context instance. To set the relationships you can directly use the foreign key properties like Product.ProductSubcategoryID and change the value in order to manage the category this product belongs to.
If you want to create navigation members like Product.Category of type ProductCategory, this is also possible but would require a lot more manual operations, including writing these properties manually and extending the OpenAccess metadata. This will have to be done for each association you want to create between classes from different rlinq files. If this is really what you are trying to achieve, just let me know and I will extend the example. I hope that helps.

Kind regards,
Alexander
the Telerik team
Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
0
rebtech
Top achievements
Rank 1
answered on 09 May 2011, 04:57 PM
can you please expand this.  This is exactly what I need to do.  My database has 276 tables, and I still have about 40 more to add. I would like to split the diagrams up based on the schemas, and I will need to associate between them sometimes between several diagrams especially between the membership schema since members are related to just about all of them.
0
Alexander
Telerik team
answered on 16 May 2011, 08:06 AM
Hi rebtech,

The updated demo is attached to this post. The main idea is that a fluent metadata source is used to merge the two rlinq models and define an association between the Product and ProductCategory classes. Please note that you will have to manually extend the two persistent classes and add the needed navigational properties (Product.Category and ProductCategory.Products). Additional associations can be defined in the PrepareMapping method in the same manner as it is done for the Product/ProductCategory association.

Greetings,
Alexander
the Telerik team
Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
Tags
Design Time (Visual Designer & Tools)
Asked by
Ron
Top achievements
Rank 1
Answers by
Alexander
Telerik team
rebtech
Top achievements
Rank 1
Share this question
or