-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppDbContext.cs
More file actions
40 lines (32 loc) · 1.25 KB
/
Copy pathAppDbContext.cs
File metadata and controls
40 lines (32 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using BugTrackerProject.Models.SubModels;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BugTrackerProject.Models
{
public class AppDbContext : IdentityDbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options): base(options)
{
}
public DbSet<BugAttributes> Bugs { get; set; }
public DbSet<ProjectAttributes> Projects { get; set; }
public DbSet<ScreenShots> ScreenShots { get; set; }
public DbSet<ProjectBugs> ProjectBugs { get; set; }
public DbSet<UsersAssigned> UsersAssigned { get; set; }
public DbSet<Comment> Comments { get; set; }
public DbSet<BugHistory> BugHistory { get; set; }
public DbSet<ProjectHistory> ProjectHistory { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
foreach (var foreignKey in modelBuilder.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys()))
{
foreignKey.DeleteBehavior = DeleteBehavior.Restrict;
}
}
}
}