Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. using Microsoft.EntityFrameworkCore;
  2. using System.Collections.Generic;
  3.  
  4. namespace EFGetStarted.AspNetCore.NewDb.Models
  5. {
  6. public class BloggingContext : DbContext
  7. {
  8. public BloggingContext(DbContextOptions<BloggingContext> options)
  9. : base(options)
  10. { }
  11.  
  12. public DbSet<Blog> Blogs { get; set; }
  13. public DbSet<Post> Posts { get; set; }
  14. }
  15.  
  16. public class Blog
  17. {
  18. public int BlogId { get; set; }
  19. public string Url { get; set; }
  20.  
  21. public List<Post> Posts { get; set; }
  22. }
  23.  
  24. public class Post
  25. {
  26. public int PostId { get; set; }
  27. public string Title { get; set; }
  28. public string Content { get; set; }
  29.  
  30. public int BlogId { get; set; }
  31. public Blog Blog { get; set; }
  32. }
  33. }
  34.  
  35. using System;
  36. using System.Collections.Generic;
  37. using System.Linq;
  38. using System.Threading.Tasks;
  39. using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
  40.  
  41. namespace EFGetStarted.AspNetCore.NewDb.Models
  42. {
  43. // Add profile data for application users by adding properties to the ApplicationUser class
  44. public class ApplicationUser : IdentityUser
  45. {
  46. }
  47. }
  48.  
  49. using System;
  50. using System.Collections.Generic;
  51. using System.Linq;
  52. using System.Threading.Tasks;
  53. using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
  54. using Microsoft.EntityFrameworkCore;
  55. using EFGetStarted.AspNetCore.NewDb.Models;
  56. namespace EFGetStarted.AspNetCore.NewDb.Data
  57. {
  58. public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
  59. {
  60. public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
  61. : base(options)
  62. {
  63. }
  64. protected override void OnModelCreating(ModelBuilder builder)
  65. {
  66. base.OnModelCreating(builder);
  67. // Customize the ASP.NET Identity model and override the defaults if needed.
  68. // For example, you can rename the ASP.NET Identity table names and more.
  69. // Add your customizations after calling base.OnModelCreating(builder);
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement