Created
May 25, 2019 19:20
-
-
Save ParmanBabra/78114a17f1f225da5fb917a35d312bc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ShoppingContext : DbContext | |
{ | |
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ | |
modelBuilder.Entity<Account>(builder => | |
{ | |
... | |
builder.HasOne(en => en.ShoppingCart) //ระบุความสัมพันธ์แบบ 1 ต่อ 1 | |
.WithOne(en => en.Account) | |
.HasForeignKey<Account>(en => en.UserName); //ระบุ Property ที่เป็น FK | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment