Having these two
classes public class User
{
[Key]
public int UserId { get;
set; }
public string
UserName { get; set;
}
//[InverseProperty("User")]
public Membership
Membership { get; set;
}
}
public
class Membership
{
[Key]
public int UserId { get;
set; }
public string
Password { get; set;
}
public string Email {
get; set; }
//[InverseProperty("Membership")]
public User User {
get; set; }
}
InverseProperty attribute seems to not work, so I defined the relation in FluentAPI :
modelBuilder.Entity<Membership>()
.HasRequired(p => p.User)
.WithOptional(u => u.Membership);
Is that the only way to define such relation ? is there any syntax possible with AOP ?
Regards,
Edited by Walid - 14-Dec-2011 at 1:11pm