Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Entity Model and Foreign Key Names

Status
Not open for further replies.

MomentSurfer

IS-IT--Management
Mar 7, 2006
13
CA
Greetings,

I am developing my first ASP.NET application that uses the new Entity Framework in .NET 3.5 SP1. I am hoping someone can provide me with a tip for how-to name the Associations for my modeled entities.

I have assigned custom foreign key names in my Microsoft SQL Server 2008 database. I would have thought the EM generator would have automatically used my foreign key names for the Association names that it creates in the entity model. Unfortunately, the generator assigns its own names (ie. Project_UserAccount, Project_UserAccount1, Project_UserAccount2). I found how-to assign my own association names, manually, by editing the entity associations after the model is automatically generated. The issue with this is if I need to generate the entity model my changes could be lost.

Are there any better approaches?

Here is a sample of my table:

Project
- ProjectID
- ProjectName
- CreatedBy (maps to UserAccountID on UserAccount table)
- LastModifiedBy (maps to UserAccountID on UserAccount table)
- ProjectOwner (maps to UserAccountID on UserAccount table)

I want to refer to my entity as project.ProjectOwner instead of the default assigned association name of project.UserAccount2.

Any help you can provide is greatly appreciated.

Thanks,

MomentSurfer
 
if you are moving towards a domain model and ORM frameworks, don't waist your time with EF. I would recommend NHibernate instead. It is a proven framework that far out performs EF and others. the 2 main resources for NH are

there are also countless blogs on the framework as well. most notably: and
Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top