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

Designer generates wrong FK associations

3 Answers 89 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.
DMC Helpdesk
Top achievements
Rank 1
DMC Helpdesk asked on 09 Jun 2010, 07:53 PM
Hi,
I have 2 tables in oracle: Inventory and laptops, where inventory table has a primary key (ID), and laptops table has foreign key to inventory id (Inventory_Id).As you can see the link should be one-to-one since a laptop record maps to a 1 inventory record.When using the add new item 'Telerik OpenAccess domain model' to generate the domain, the designer renders the 2 entities with the following properties:
-Laptop entity has a property 'InventoryId' but lacks the 'Inventory' property which should map to an entity of type Inventory
-Inventory entity has a property 'Laptops' which maps to an IList of type Laptop, and the correct property should be of type Laptop since it maps to a 1 laptop only.

My question: how can get the designer to generate the correct associations without editing the C sharp source code, as this is really disappointing me having waited 2 years for the ORM visual designer.

Thanks

My Development Environment:
VS 2010
OpenAccess (downloaded Jun 2010)
Oracle 9i Release 2
C# Class Library project.



3 Answers, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 10 Jun 2010, 01:01 PM
Hi DMC Helpdesk,

 Is the Inventory_ID a primary key of the Laptops table? If it is than in deed this is a one-to-one relation but unfortunately the OpenAccess runtime does not support one-to-one relations -  one-to-many and many-to-many  are the only setups supported. However if the Inventory_ID is just a foreign key column in the Laptops table, then this is a classical 1:n scenario as more than one laptop entry can point to one and the same Inventory entry e.g. one Inventory can have more than one Laptop. If that is the case than you should have end points on both classes - Laptop should have an Inventory and the Inventory should have a collection of Laptops. Having no reference on the Laptop side is rally not the expected behavior in all cases. We are looking forward on further collaborating on this issue so that we can find a decent solution for your obstacles. If it is possible for you to send us a copy of part of your database schema, it will be the best way for us to try and reproduce your case, hence the solution would come much faster.

Best wishes,
Zoran
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.
0
DMC Helpdesk
Top achievements
Rank 1
answered on 14 Jun 2010, 01:38 PM
Thanks Zoran,

The Inventory_ID is NOT just a foreign key column in the Laptops table, but is also a primary key because the relationship is one-to-one.
We store inventory common data in the table Inventory (ID,Name,Type)  and we store more data in the relevant table (e.g. Laptops, Monitors, Printers).This gives me the ability to store data relevant to the inventory item (e.g. I have a field 'Page' on the printers table to store the number of pages the printer can print).The field 'Type' in inventory table refers to the type of the inventory (e.g. 1=Laptop,2=Monitor and so on).

Here is my tables structure:

Inventory:
ID varchar2
Name varchar2
Type number (foreign key to a table Inventory_types which has ID and name)

Laptops:
Inventory_Id varchar2 (primary key and foreign key linking to the inventory table)
more fields here........

Another question: how can expose a 1-to-1 property on both sides (e.g. on the inventory entity, I would like to have a property called Laptop of type Laptop.On the Laptop entity, I need to have a property Inventory that points me to the inventory entity associated with the current entity.

Thanks
0
Zoran
Telerik team
answered on 16 Jun 2010, 09:17 AM
Hello DMC Helpdesk,

 I have a clear idea about your model now. Unfortunately, one-to-one relations are not supported for composition scenarios as you are requesting as the runtime does not handle them in the manner you are requesting. That means that you are not able to create such association in the designer. However we are perfectly aware that this is a completely valid setup and handling these kind of scenarios is a bigger part of our to-do list for the improvements in the runtime system. At the moment, we are handling one-to-one relations only in an inheritance approach. You are able to make the Laptop class to inherit from the Inventory class and therefore you will be able to persist both kind of objects, but I suppose that is not your preferred workflow.
We are sorry for the inconvenience this might have caused you. We will notify you as soon as such functionality is provided by our product.

Kind regards,
Zoran
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
Design Time (Visual Designer & Tools)
Asked by
DMC Helpdesk
Top achievements
Rank 1
Answers by
Zoran
Telerik team
DMC Helpdesk
Top achievements
Rank 1
Share this question
or