Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace PersonalFoodHelper.Data
- {
- using Microsoft.AspNetCore.Identity;
- using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore;
- using PersonalFoodHelper.Data.MappingTables;
- public class ApplicationDbContext : IdentityDbContext
- {
- public DbSet<Food> Foods { get; set; }
- public DbSet<Meal> Meals { get; set; }
- public DbSet<Breakfast> Breakfasts { get; set; }
- public DbSet<Lunch> Lunches { get; set; }
- public DbSet<Dinner> Dinners { get; set; }
- public DbSet<UserLunch> UserLunches { get; set; }
- public DbSet<UserBreackfast> UserBreackfasts { get; set; }
- public DbSet<UserDinner> UserDinners { get; set; }
- public DbSet<BreakfastFood> BreakfastFoods { get; set; }
- public DbSet<BreakfastMeal> BreakfastMeals { get; set; }
- public DbSet<LunchFood> LunchFoods { get; set; }
- public DbSet<LunchMeal> LunchMeals { get; set; }
- public DbSet<DinnerFood> DinnerFoods { get; set; }
- public DbSet<DinnerMeal> DinnerMeals { get; set; }
- public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
- : base(options)
- {
- }
- protected override void OnModelCreating(ModelBuilder builder)
- {
- builder.Entity<UserBreackfast>()
- .HasKey(x => new { x.BreakfastId, x.UserId });
- builder.Entity<UserDinner>()
- .HasKey(x => new { x.DinnerId, x.UserId });
- builder.Entity<UserLunch>()
- .HasKey(x => new { x.LunchId, x.UserId });
- builder.Entity<DinnerFood>()
- .HasKey(x => new { x.FoodId, x.DinnerId });
- builder.Entity<DinnerMeal>()
- .HasKey(x => new { x.MealId, x.DinnerId });
- builder.Entity<LunchFood>()
- .HasKey(x => new { x.FoodId, x.LunchId });
- builder.Entity<LunchMeal>()
- .HasKey(x => new { x.MealId, x.LunchId });
- builder.Entity<BreakfastFood>()
- .HasKey(x => new { x.FoodId, x.BreakfastId });
- builder.Entity<BreakfastMeal>()
- .HasKey(x => new { x.MealId, x.BreakfastId });
- builder.Entity<FoodMeals>()
- .HasKey(x => new { x.FoodId, x.MealId });
- builder.Entity<IdentityUserLogin<string>>()
- .HasKey(x => x.UserId);
- builder.Entity<IdentityUserRole<string>>()
- .HasKey(x => x.RoleId);
- builder.Entity<IdentityUserClaim<string>>()
- .HasKey(x => x.Id);
- builder.Entity<IdentityUserToken<string>>()
- .HasKey(x => x.UserId);
- builder.Entity<IdentityUser<string>>()
- .HasKey(x => x.Id);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement