2

Hi I have these two tables:

Client:

    -IdClient: primary key
    -Name
    -IdAccount

Account:

    -IdAccount: primary key
    -Total

I one to create a 1 to 1 relationship using IdAccount from Client table and IdAccount from Account table. I read that onley 1 to 1 relationships can be done in Visual studio between keys, in this case IdClient-IdAccount, how can I make a one to one relationship with IdAccount and IdAccount? If I make one it does it as 1 to many =S

Thanks!

AMadmanTriumphs
  • 4,888
  • 3
  • 28
  • 44
bb2
  • 97
  • 2
  • 9

1 Answers1

0

This question pretty much covers this entire issue (I reckon that's what you have read). Object relational models define one to many relationships in such cases because the actual data model (i.e. the database) allows one to many usage.

If you really have a special need (consider that in the future you might want to allow a single client to have separate accounts as is the normal case in a bank, so leaving the relationship one-to-many may be a good idea) you can fiddle with endpoint multiplicities.

Community
  • 1
  • 1
mcyalcin
  • 2,074
  • 1
  • 15
  • 12
  • It's not exactly a bank a user is only allowed to have ONE account. I checked how to do this in Entity framework model, and it's possible. What I don't know is the logic, how does Client know which Account is his?? I ask because in the Client table there won't be a fiel "idAccount" and vice versa. I checked this too http://mosesofegypt.net/post/Inheritance-and-Associations-with-Entity-Framework-Part-2.aspx – bb2 Feb 26 '11 at 06:04
  • As I said above, you can try changing endpoint multiplicities. I think this is a similar case: http://stackoverflow.com/questions/2141328/unique-keys-not-recognized-by-entity-framework/2326859#2326859 – mcyalcin Feb 26 '11 at 13:07