I'd like to map a one-to-one relationship using Entity Framework 5 Code First like this:
public class User
{
public Guid Id { get; set; }
}
public class Profile
{
public User Owner { get; set; }
}
Note that database Profile table schema has a primary key UserId
that's a foreign key to Users table.
I'd like to know if I can avoid an artificial identifier in Profiles table.
Thank you in advance!
UPDATE
Well, it seems that both answers of Eranga and hvd are useful. With some own contribution, I got a transaction creating an user with the belonging profile successfully.
- hvd => There's no need of the artificial identifier in the object model.
- Erlanga => Your approach works BUT it forces you to have an [Id] column in the database.
Does anyone found a way of avoiding the artificial identifier even in the database table?