新增全局异常捕获
This commit is contained in:
@@ -20,6 +20,8 @@ namespace Apimanager_backend.Data
|
||||
public DbSet<Order> Orders { get; set; }
|
||||
//用户已订购套餐表
|
||||
public DbSet<UserPackage> UserPackages { get; set; }
|
||||
//用户角色表
|
||||
public DbSet<UserRole> UserRoles { get; set; }
|
||||
public ApiContext(DbContextOptions<ApiContext> options) : base(options) { }
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using Apimanager_backend.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Apimanager_backend.Data
|
||||
{
|
||||
public class UserRoleConfig : IEntityTypeConfiguration<UserRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserRole> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
//自增
|
||||
builder.Property(x => x.Id)
|
||||
.ValueGeneratedOnAdd();
|
||||
//外键
|
||||
builder.HasOne(x => x.User)
|
||||
.WithMany(u => u.Roles)
|
||||
.HasForeignKey(x => x.UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user