How to declare a one to one relationship using Entity Framework 4 Code First (POCO)?
I found this question (one-to-one relationships in Entity Framework 4) , but the article that the answer references was not useful (there is one line of code that is a 1-1 relationship, but no mention of how to define it).
Are you just looking for something like this?
EDIT: Yeah I didn’t have VS in front of me but you need to add the following line in the
UserMappinginstead of the currentHasRequiredand also add aProfileIdproperty (instead ofProfile_Idthat you added):I currently don’t think there’s a way around this, but I’m sure it’ll change since we’re only in CTP4. It’d be nice if I could say:
This way I wouldn’t have to include a
ProfileIdproperty. Maybe there is a way around this currently and it’s still to early in the morning for me to think :).Also remember to call
.Include("Profile")if you want to include a “navigational property”.