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.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. namespace Teknik.Models
  12. {
  13. public class TeknikEntities : DbContext
  14. {
  15. // Users
  16. public DbSet<User> Users { get; set; }
  17. public DbSet<Group> Groups { get; set; }
  18. public DbSet<Role> Roles { get; set; }
  19. // User Settings
  20. public DbSet<UserSettings> UserSettings { get; set; }
  21. public DbSet<BlogSettings> BlogSettings { get; set; }
  22. public DbSet<UploadSettings> UploadSettings { get; set; }
  23. // Blogs
  24. public DbSet<Blog> Blogs { get; set; }
  25. public DbSet<BlogPost> BlogPosts { get; set; }
  26. public DbSet<BlogPostComment> BlogComments { get; set; }
  27. // Contact
  28. public DbSet<Contact> Contact { get; set; }
  29. // Uploads
  30. public DbSet<Upload> Uploads { get; set; }
  31. // Pastes
  32. public DbSet<Paste> Pastes { get; set; }
  33. // Podcasts
  34. public DbSet<Podcast> Podcasts { get; set; }
  35. public DbSet<PodcastFile> PodcastFiles { get; set; }
  36. public DbSet<PodcastComment> PodcastComments { get; set; }
  37. protected override void OnModelCreating(DbModelBuilder modelBuilder)
  38. {
  39. modelBuilder.Entity<User>()
  40. .HasRequired(a => a.UserSettings)
  41. .WithRequiredPrincipal(a => a.User);
  42. modelBuilder.Entity<User>()
  43. .HasRequired(a => a.BlogSettings)
  44. .WithRequiredPrincipal(a => a.User);
  45. modelBuilder.Entity<User>()
  46. .HasRequired(a => a.UploadSettings)
  47. .WithRequiredPrincipal(a => a.User);
  48. modelBuilder.Entity<UserSettings>()
  49. .HasRequired(a => a.BlogSettings)
  50. .WithRequiredPrincipal(a => a.UserSettings);
  51. modelBuilder.Entity<UserSettings>()
  52. .HasRequired(a => a.UploadSettings)
  53. .WithRequiredPrincipal(a => a.UserSettings);
  54. modelBuilder.Entity<BlogSettings>()
  55. .HasRequired(a => a.UploadSettings)
  56. .WithRequiredPrincipal(a => a.BlogSettings);
  57. // Users
  58. modelBuilder.Entity<User>().ToTable("Users");
  59. modelBuilder.Entity<Group>().ToTable("Groups");
  60. modelBuilder.Entity<Role>().ToTable("Roles");
  61. // User Settings
  62. modelBuilder.Entity<UserSettings>().ToTable("Users");
  63. modelBuilder.Entity<BlogSettings>().ToTable("Users");
  64. modelBuilder.Entity<UploadSettings>().ToTable("Users");
  65. // Blogs
  66. modelBuilder.Entity<Blog>().ToTable("Blogs");
  67. modelBuilder.Entity<BlogPost>().ToTable("BlogPosts");
  68. modelBuilder.Entity<PodcastComment>().ToTable("BlogComments");
  69. // Contact
  70. modelBuilder.Entity<Contact>().ToTable("Contact");
  71. // Uploads
  72. modelBuilder.Entity<Upload>().ToTable("Uploads");
  73. // Pastes
  74. modelBuilder.Entity<Paste>().ToTable("Pastes");
  75. // Podcasts
  76. modelBuilder.Entity<Podcast>().ToTable("Podcasts");
  77. modelBuilder.Entity<PodcastFile>().ToTable("PodcastFiles");
  78. modelBuilder.Entity<PodcastComment>().ToTable("PodcastComments");
  79. base.OnModelCreating(modelBuilder);
  80. }
  81. }
  82. }