Skip to content

Instantly share code, notes, and snippets.

@mmilleruva
Created October 30, 2013 19:01
Show Gist options
  • Save mmilleruva/7238142 to your computer and use it in GitHub Desktop.
Save mmilleruva/7238142 to your computer and use it in GitHub Desktop.
public class PersonMap : EntityTypeConfiguration<Person>
{
public PersonMap()
{
this.ToTable("Person");
}
}
public class PersonWithPreferenceMap : PersonMap
{
public PersonWithPreferenceMap()
{
// Primary Key
this.HasKey(t => t.UserName);
// Relationships
this.HasMany(t => t.Preferences)
.WithRequired()
.HasForeignKey(t => t.Username);
this.Ignore(t => t.Orders);
}
}
public class PersonWithOrderMap : PersonMap
{
public PersonWithOrderMap()
{
// Primary Key
this.HasKey(t => t.PersonId);
// Relationships
this.HasMany(t => t.Orders)
.WithRequired()
.HasForeignKey(t => t.PersonId);
this.Ignore(t => t.Preferences);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment