Drugi
This commit is contained in:
30
ZpcBulletinBoard/Data/ApplicationDbContext.cs
Normal file
30
ZpcBulletinBoard/Data/ApplicationDbContext.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ZpcBulletinBoard.Models;
|
||||
using ZpcBulletinBoard.Models.Editor;
|
||||
|
||||
namespace ZpcBulletinBoard.Data
|
||||
{
|
||||
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
||||
: IdentityDbContext<IdentityApplicationUser, IdentityApplicationRole, int>(options)
|
||||
{
|
||||
public DbSet<Note> Notes { get; set; }
|
||||
public DbSet<BulletinBoard> BulletinBoards { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
//Relacije
|
||||
modelBuilder.Entity<BulletinBoard>()
|
||||
.HasMany(t => t.Notes)
|
||||
.WithOne(t => t.BulletinBoard)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user