Skip to content

Instantly share code, notes, and snippets.

@gabrieljoelc
Created November 7, 2013 03:09
Show Gist options
  • Save gabrieljoelc/7348340 to your computer and use it in GitHub Desktop.
Save gabrieljoelc/7348340 to your computer and use it in GitHub Desktop.
public abstract class BillingDetail
{
public int BillingDetailId { get; set; }
public string Owner { get; set; }
public string Number { get; set; }
}
[Table("BankAccounts")]
public class BankAccount : BillingDetail
{
public string BankName { get; set; }
public string Swift { get; set; }
}
[Table("CreditCards")]
public class CreditCard : BillingDetail
{
public int CardType { get; set; }
public string ExpiryMonth { get; set; }
public string ExpiryYear { get; set; }
}
public class InheritanceMappingContext : DbContext
{
public DbSet<BillingDetail> BillingDetails { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<BankAccount>().ToTable("BankAccounts");
modelBuilder.Entity<CreditCard>().ToTable("CreditCards");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment