no

How to Declare Foreign Key in Entity Framework

There are 2 ways to declare foreign key in entity framework. Assuming we have 2 entities aspnet_Users and Person, which are link via UserId ...

There are 2 ways to declare foreign key in entity framework. Assuming we have 2 entities aspnet_Users and Person, which are link via UserId from aspnet_Users. 1.)
class Person {
  public Guid UserId { get;set; }
  [ForeignKey("UserId")]
  public virtual AspnetUser AspnetUser { get; set; }
}
2.)
  [ForeignKey("AspnetUser")]
  public Guid UserId { get;set; }  
  public virtual AspnetUser AspnetUser { get; set; }

Related

c# 8991854298901029294

Post a Comment Default Comments

Outsourcing

Are you looking for freelancers in the Philippines? Get in touch.

Donations

If you like what I do, you can support this channel by buying me a coffee. I would be grateful for your contribution! Your donations will help me create more FREE online courses and learning materials for programmers and remote workers.

item