Navigation Property Names

Jan 7, 2011 at 5:34 AM

After successfully building an nHydrate EF based WPF app, I decided that I wanted to rename all of the core assemblies (basically, I wrote the app originally for personal use, but I think it might be useful to others, at least as an example of an nHydrate-powered WPF app, so I want to make the assembly names more "generic").

I thought the easiest and cleanest way to do this was to just create an entirely new wsgen schema file. My schema doesn't have a lot of tables, so setting all the facades correctly wouldn't take too long. 

In the course of doing this, however, I'm running into some odd problems. In the original schema there's a many-to-many relationship between a Clip table and a Disc table, by way of a linking table called DiscClip. They aren't in an "associative relationship", in nHydrate terms, because the linking table's primary key contains one more field than just the ID fields from the Disc and Clip tables.

When I generated the classes from the wsgen schema file, the navigation properties were named completely differently than in my original schema. For example, the original schema produced a Clip class that had a navigation property called FkDiscClipList, which returns an EntityCollection<DiscClip>. In the new schema, the property ended up being called something weird looking with a lot of lower case names and embedded underscores (sorry about not being to tell you exactly what it was, but I deleted the file). It looked to me like the navigation property got named based on the underlying database field names, rather than the CodeFacade names I added to the wsgen schema file (in both cases I put CodeFacade names on both the tables and the columns).

I obviously did something goofy the second time around, but it's not obvious what. Can someone suggest things I might check? Thanks!

- Mark

Coordinator
Mar 26, 2011 at 4:15 AM

Sorry for the tardiness but i was looking at some older non-addressed issues. There is a TransformNames property on the model that does some fancy manipulate with underscores and such in database names. If this got flipped somehow your database names with underscores will include the underscores in code is this is false. By default this is off so your model names match your database names. Can you post the names that have issues? Is this still an issue?

Mar 26, 2011 at 4:54 AM

No worries. It's been long enough that I don't remember how I resolved the issue, but it didn't prevent me from completing the project. Thanks for following up.