39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ViraScraper.Models
|
|
{
|
|
public class ScrapDbContext : DbContext
|
|
{
|
|
public DbSet<Hashtag> Hashtags { get; set; }
|
|
public DbSet<Synonyms> Synonymses { get; set; }
|
|
|
|
public ScrapDbContext(DbContextOptions<ScrapDbContext> options) : base(options) { }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Synonyms>()
|
|
.HasOne<Hashtag>()
|
|
.WithMany()
|
|
.HasForeignKey(s=>s.HashtagAId)
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
modelBuilder.Entity<Synonyms>()
|
|
.HasOne<Hashtag>()
|
|
.WithMany()
|
|
.HasForeignKey(s => s.HashtagBId)
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
|
|
public override void Dispose()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|