-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataContext.cs
More file actions
34 lines (32 loc) · 1.25 KB
/
DataContext.cs
File metadata and controls
34 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
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NetCoreBBS.Entities;
namespace NetCoreBBS.Infrastructure
{
public class DataContext : IdentityDbContext<User>
{
public DataContext(DbContextOptions<DataContext> options)
: base(options)
{
}
public DbSet<Topic> Topics { get; set; }
public DbSet<TopicReply> TopicReplys { get; set; }
public DbSet<TopicNode> TopicNodes { get; set; }
public DbSet<UserMessage> UserMessages { get; set; }
public DbSet<UserCollection> UserTopics { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Topic>().ToTable("Topic");
modelBuilder.Entity<TopicReply>().ToTable("TopicReply");
modelBuilder.Entity<TopicNode>().ToTable("TopicNode");
modelBuilder.Entity<User>().ToTable("User");
modelBuilder.Entity<UserMessage>().ToTable("UserMessage");
modelBuilder.Entity<UserCollection>().ToTable("UserCollection");
}
}
}