代码拉取完成,页面将自动刷新
using Microsoft.EntityFrameworkCore;
using System.Text.RegularExpressions;
namespace Scheduler.Model
{
public class SchedulerContext : DbContext
{
public SchedulerContext(DbContextOptions<SchedulerContext> options)
: base(options)
{
}
public DbSet<SysUserInfo> Users { get; set; }
public DbSet<UserRole> UserRoles { get; set; }
public DbSet<Permission> Permissions { get; set; }
public DbSet<Modules> Modules { get; set; }
public DbSet<Role> Roles { get; set; }
public DbSet<RoleModulePermission> RoleModulePermissions { get; set; }
//已经改用EFCore.NamingConventions包的UseSnakeCaseNamingConvention,不需要再使用下面的代码
//protected override void OnModelCreating(ModelBuilder modelBuilder)
//{
// // 自动将实体类名和属性名转换为 snake_case
// foreach (var entity in modelBuilder.Model.GetEntityTypes())
// {
// // 表名转换(如 UserProfile -> user_profile)
// entity.SetTableName(ConvertToSnakeCase(entity.GetTableName()));
// // 列名转换(如 CreatedAt -> created_at)
// foreach (var property in entity.GetProperties())
// {
// property.SetColumnName(ConvertToSnakeCase(property.GetColumnName()));
// }
// }
//}
//private static string ConvertToSnakeCase(string input)
//{
// if (string.IsNullOrEmpty(input)) return input;
// return Regex.Replace(input, "(?<=[a-z])([A-Z])", "_$1").ToLower();
//}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。