Guest User

Untitled

a guest
Aug 19th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. Adding multiple inherited instances of diferent children types in a TPT Mapping EF4.1
  2. public abstract class Person
  3. {
  4. public int Id {get;set;}
  5. }
  6.  
  7. public class Customer : Person
  8. {
  9. public string Name {get;set;}
  10. }
  11. public class User : Person
  12. {
  13. public string Password {get;set;}
  14. }
  15.  
  16. context.Set<Customer>().Add(new Customer { Name = "X" });
  17. context.SaveChanges();
  18.  
  19. Persons
  20. Id: 1
  21.  
  22. Customers
  23. Id: 1
  24. Name: X
  25.  
  26. context.Set<Customer>().Add(new User { Id = 1, Password = "0" });
  27. context.SaveChanges();
Add Comment
Please, Sign In to add comment