Discover One to One Relationship

Apr 13 at 1:45 AM
Is there a way to discover whether a table has a one-to-one relationship to another table. For example:

class User{
public string UserDetailId {get; set; }
public virtual UserDetail UserDetail {get; set; }

class UserDetail {
public string UserDetailId {get; set; }
public virtual User User {get; set; }

UserDetailId would give a ForeignKey however, UserDetail would not relate directly back to User
Apr 27 at 10:40 AM
The model contains both sides of the foreign key relationship, so yes, you can check across.
  • User has a foreign key to UserDetail - this will appear in the "ForeignKeys" property.
  • UserDetail does not have a fk to User, but the DatabaseTable model has the inverse relationship to User in the "ForeignKeyChildren" property.