The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TeknikEntities.cs 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using Microsoft.AspNet.Identity.EntityFramework;
  2. using System.Data.Entity;
  3. using System.Data.Entity.Infrastructure;
  4. using Teknik.Areas.Blog.Models;
  5. using Teknik.Areas.Profile.Models;
  6. using Teknik.Areas.Contact.Models;
  7. using Teknik.Migrations;
  8. using Teknik.Areas.Upload.Models;
  9. using Teknik.Areas.Paste.Models;
  10. using Teknik.Areas.Podcast.Models;
  11. using Teknik.Areas.Transparency.Models;
  12. namespace Teknik.Models
  13. {
  14. public class TeknikEntities : DbContext
  15. {
  16. // Users
  17. public DbSet<User> Users { get; set; }
  18. public DbSet<Group> Groups { get; set; }
  19. public DbSet<Role> Roles { get; set; }
  20. // User Settings
  21. public DbSet<UserSettings> UserSettings { get; set; }
  22. public DbSet<BlogSettings> BlogSettings { get; set; }
  23. public DbSet<UploadSettings> UploadSettings { get; set; }
  24. // Blogs
  25. public DbSet<Blog> Blogs { get; set; }
  26. public DbSet<BlogPost> BlogPosts { get; set; }
  27. public DbSet<BlogPostComment> BlogComments { get; set; }
  28. // Contact
  29. public DbSet<Contact> Contact { get; set; }
  30. // Uploads
  31. public DbSet<Upload> Uploads { get; set; }
  32. // Pastes
  33. public DbSet<Paste> Pastes { get; set; }
  34. // Podcasts
  35. public DbSet<Podcast> Podcasts { get; set; }
  36. public DbSet<PodcastFile> PodcastFiles { get; set; }
  37. public DbSet<PodcastComment> PodcastComments { get; set; }
  38. // Transparency
  39. public DbSet<Transaction> Transactions { get; set; }
  40. protected override void OnModelCreating(DbModelBuilder modelBuilder)
  41. {
  42. modelBuilder.Entity<User>()
  43. .HasRequired(a => a.UserSettings)
  44. .WithRequiredPrincipal(a => a.User);
  45. modelBuilder.Entity<User>()
  46. .HasRequired(a => a.BlogSettings)
  47. .WithRequiredPrincipal(a => a.User);
  48. modelBuilder.Entity<User>()
  49. .HasRequired(a => a.UploadSettings)
  50. .WithRequiredPrincipal(a => a.User);
  51. modelBuilder.Entity<UserSettings>()
  52. .HasRequired(a => a.BlogSettings)
  53. .WithRequiredPrincipal(a => a.UserSettings);
  54. modelBuilder.Entity<UserSettings>()
  55. .HasRequired(a => a.UploadSettings)
  56. .WithRequiredPrincipal(a => a.UserSettings);
  57. modelBuilder.Entity<BlogSettings>()
  58. .HasRequired(a => a.UploadSettings)
  59. .WithRequiredPrincipal(a => a.BlogSettings);
  60. // Users
  61. modelBuilder.Entity<User>().ToTable("Users");
  62. modelBuilder.Entity<Group>().ToTable("Groups");
  63. modelBuilder.Entity<Role>().ToTable("Roles");
  64. // User Settings
  65. modelBuilder.Entity<UserSettings>().ToTable("Users");
  66. modelBuilder.Entity<BlogSettings>().ToTable("Users");
  67. modelBuilder.Entity<UploadSettings>().ToTable("Users");
  68. // Blogs
  69. modelBuilder.Entity<Blog>().ToTable("Blogs");
  70. modelBuilder.Entity<BlogPost>().ToTable("BlogPosts");
  71. modelBuilder.Entity<PodcastComment>().ToTable("BlogComments");
  72. // Contact
  73. modelBuilder.Entity<Contact>().ToTable("Contact");
  74. // Uploads
  75. modelBuilder.Entity<Upload>().ToTable("Uploads");
  76. // Pastes
  77. modelBuilder.Entity<Paste>().ToTable("Pastes");
  78. // Podcasts
  79. modelBuilder.Entity<Podcast>().ToTable("Podcasts");
  80. modelBuilder.Entity<PodcastFile>().ToTable("PodcastFiles");
  81. modelBuilder.Entity<PodcastComment>().ToTable("PodcastComments");
  82. // Transparency
  83. modelBuilder.Entity<Transaction>().ToTable("Transactions");
  84. base.OnModelCreating(modelBuilder);
  85. }
  86. }
  87. }