Created
December 7, 2018 17:10
-
-
Save milannankov/f6c2942c78b37b3d8e52eafa0a897fe9 to your computer and use it in GitHub Desktop.
value-objects-model-creation
This file contains hidden or 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
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ | |
modelBuilder.Entity<Company>().OwnsMany<CompanyAddress>("Addresses", a => | |
{ | |
a.HasForeignKey("CompanyId"); | |
a.Property(ca => ca.City); | |
a.Property(ca => ca.AddressLine1); | |
a.HasKey("CompanyId", "City", "AddressLine1"); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment