New Posts New Posts RSS Feed: Adding navigation properties
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Adding navigation properties

 Post Reply Post Reply
Author
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Topic: Adding navigation properties
    Posted: 24-Feb-2009 at 12:11pm
Hi,

Are there any plans to support adding navigation properties through the object mapper like in classic? One database we are currently working against does not have relationships setup in the database, and we cannot add them due to legacy applications currently in use. I realize you can do it with the EF designer but frankly it is horrible to work with!

Thanks,

Mark
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 25-Feb-2009 at 8:07am
There are plans to beef up the functionality within the Object Mapper, but we just haven't had the time and resources to get to it yet.  So unfortunately for now you will still need to use the EDM designer (and we agree, it is horrible to work with :)).
Back to Top
pucsoftware View Drop Down
Groupie
Groupie
Avatar

Joined: 15-Apr-2008
Location: United States
Posts: 46
Post Options Post Options   Quote pucsoftware Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2009 at 8:44am
I started creating a new model and I'm having problems with renaming navigation properties in the object model. I'll be working with if for a while, changing the names of the Navigation properties and the Association names, periodically saving it. Eventually, I get a nondescript error when saving. I end up having to close the object mapper without saving the changes. However, the model is in an invalid state. The .Net entity designer won't display the objects and shows an error:
 
Warning 1 Error 11004: Association 'FK_SX_STAP_REJECTION_LU_STAP_REJECTION' has no association set. D:\Projects\Windows\Stap\StapDb\StapEntityModel.edmx 1516 9 StapDb
I worked on this all day Friday. I ended up having to start over with the project. I've had to start completely over 3 times now and currently it is corrupted. Should I be renaming the Navigation and Association properties? I've done this before and never had any problems. The only difference that I can think of is with main table. It has several fields that are related to the same lookup table. for example:
 
DEVICE_CODE1 -> LU_DEVICE_CODE
DEVICE_CODE2 -> LU_DEVICE_CODE
DEVICE_CODE3 -> LU_DEVICE_CODE
DEVICE_CODE4 -> LU_DEVICE_CODE
 
The object mapper automatically names them:
LU_DEVICE_CODE
LU_DEVICE_CODE1
LU_DEVICE_CODE2
LU_DEVICE_CODE3
 
Which, to me, makes it a little confusing since the Navigations are not corresponding to the original fields:
 
DEVICE_CODE1 -> LU_DEVICE_CODE    ( this one defaults to no number )
DEVICE_CODE2 -> LU_DEVICE_CODE1
DEVICE_CODE3 -> LU_DEVICE_CODE2
DEVICE_CODE4 -> LU_DEVICE_CODE3
 
So, I was renaming them to be:
 
DEVICE_CODE1 -> LuDeviceCode1
DEVICE_CODE2 -> LuDeviceCode2
DEVICE_CODE3 -> LuDeviceCode3
DEVICE_CODE4 -> LuDeviceCode4
 
This table has 4 sets of fields that are setup this way. It's a legacy application that I can't change, too.
Not sure if this causes the problem as the errors don't seem to reflect these particular fields, but the results have been pretty consistent - corrupted entity model that I can't fix.
 
Any suggestions?
 
puctx
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2009 at 11:37am
Let me cook up a similar database structure and see if I can reproduce what you're seeing. I'll be back.
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2009 at 11:46am
Originally posted by pucsoftware

The object mapper automatically names them:
LU_DEVICE_CODE
LU_DEVICE_CODE1
LU_DEVICE_CODE2
LU_DEVICE_CODE3
 
Which, to me, makes it a little confusing since the Navigations are not corresponding to the original fields:
 
DEVICE_CODE1 -> LU_DEVICE_CODE    ( this one defaults to no number )
DEVICE_CODE2 -> LU_DEVICE_CODE1
DEVICE_CODE3 -> LU_DEVICE_CODE2
DEVICE_CODE4 -> LU_DEVICE_CODE3
 
So, I was renaming them to be:
 
DEVICE_CODE1 -> LuDeviceCode1
DEVICE_CODE2 -> LuDeviceCode2
DEVICE_CODE3 -> LuDeviceCode3
DEVICE_CODE4 -> LuDeviceCode4
 


It's the ADO.NET Entity Data Model designer, not the DevForce Object Mapper, that makes the initial name assignments. It uses the name of the type on the other end of the association (LU_DEVICE_CODE) rather than the name of the foreign key; and that's generally a good thing, since foreign keys often have names that aren't appropriate for an entity (like OrderId, etc.).   If you have more than one navigation property that returns the same type, the EF code generator then just starts appending integer suffixes, leaving it up to you to adjust the names to something that's meaningful to you.

But you should be able to do it!
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2009 at 12:22pm
Originally posted by pucsoftware

I started creating a new model and I'm having problems with renaming navigation properties in the object model. I'll be working with if for a while, changing the names of the Navigation properties and the Association names, periodically saving it. Eventually, I get a nondescript error when saving. I end up having to close the object mapper without saving the changes. However, the model is in an invalid state. The .Net entity designer won't display the objects and shows an error:
 
Warning 1 Error 11004: Association 'FK_SX_STAP_REJECTION_LU_STAP_REJECTION' has no association set. D:\Projects\Windows\Stap\StapDb\StapEntityModel.edmx 1516 9 StapDb


I failed in my effort to reproduce the problem (steps described below). Perhaps you can send us your corrupted .edmx, .ibedmx, and associated designer code files (to support@ideaBlade.com).

Here's what I did:
  1. In NorthwindIB, I added three columns to the Order table: EmployeeId2, EmployeeId3, and EmployeeId4.  (It already had an EmployeeID.)
  2. Generated a new Entity Data Model. The Order entity got navigation properties Employee, Employee1, Employee2, and Employee3.
  3. In the Object Mapper, I renamed the Employee-related navigation properties to Employee1, Employee2, Employee3, and Employee4 (moving backward from the one with the highest-numbered suffix). Saved the work and closed the Object Mapper.
  4. Reopened the Object Mapper, renamed the properties to Employee10, Employee09, Employee08, and Employee07 (again moving backward from the one with the highest-numbered suffix).  Saved the work but did not exit the Object Mapper.
  5. Renamed the properties to Employee99, Employee98, Employee97, and Employee96.  Saved the work but did not exit the Object Mapper.
  6. Repeated step 5 with different names, two more times.
  7. Closed the Object Mapper and opened the Entity Data Model in the Entity Data Model designer. No problems, all properties named as requested.

Back to Top
pucsoftware View Drop Down
Groupie
Groupie
Avatar

Joined: 15-Apr-2008
Location: United States
Posts: 46
Post Options Post Options   Quote pucsoftware Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2009 at 1:39pm
I went through all this again, slowly, and got a completed entity model. This time I did one table at a time, first doing the navigation properties, then the Associations, saving after each changes, and didn't run into any problems. Before I was jumping around changing several tables, navigation and associations, all at the same time before saving. I probably created some type of conflict without realizing it. If I can reproduce this some time in the future I'll send you the corrupted model. Thanks for your efforts.
 
 
puctx
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down