Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. public class Post
  2. {
  3. public int Id { get; set; }
  4.  
  5. [Column(TypeName = "date")]
  6. public DateTime? PostedDate { get; set; }
  7.  
  8. [Column(TypeName = "text")]
  9. public string Body { get; set; }
  10.  
  11. public int UserId { get; set; }
  12. public virtual User User { get; set; }
  13.  
  14. public Post()
  15. {
  16. Comments = new HashSet<PostComment>();
  17. }
  18. }
  19.  
  20.  
  21. public class ApplicationUser : IdentityUser
  22. {
  23. public int Id { get; set; }
  24.  
  25. [Column(TypeName = "date")]
  26. public DateTime RegistrationDate { get; set; }
  27.  
  28. [Column(TypeName = "date")]
  29. public DateTime LastVisit { get; set; }
  30.  
  31. public virtual ICollection<Post> Posts { get; set; }
  32.  
  33. public ApplicationUser()
  34. {
  35. Users = new HashSet<User>();
  36. }
  37. }
  38.  
  39. public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
  40. {
  41. public ApplicationDbContext()
  42. : base("DefaultConnection", throwIfV1Schema: false)
  43. {
  44. }
  45.  
  46. public virtual DbSet<Post> Posts { get; set; }
  47.  
  48. public static ApplicationDbContext Create()
  49. {
  50. return new ApplicationDbContext();
  51. }
  52.  
  53. protected override void OnModelCreating(DbModelBuilder modelBuilder)
  54. {
  55. ...
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement