新增全局异常捕获

This commit is contained in:
南浔
2024-11-03 00:27:20 +08:00
28 changed files with 1030 additions and 86 deletions
+2
View File
@@ -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)
{
+21
View File
@@ -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);
}
}
}