- 为全部 5 个项目(Avalonia-API、Avalonia-Common、Avalonia-EFCore、 Avalonia-PC、Avalonia-Services)中缺失注释的类、方法、属性、字段、 接口成员等补全中文 XML 文档注释 - 共修改约 37 个文件,补全约 220+ 处注释 - 修复 ServiceEndpointCollection.cs 中 MapDelete<TService> 语法错误 - 修复 PcAuthService.cs 中 const prefix 位置错乱导致编译失败的问题 - 扫描结果:缺失项 0 - 构建结果:4/4 项目编译通过
51 lines
2.0 KiB
C#
51 lines
2.0 KiB
C#
using Avalonia_EFCore.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Avalonia_EFCore.Database
|
|
{
|
|
/// <summary>
|
|
/// 应用数据库上下文 —— 继承自 Avalonia-EFCore 的 AppDbContext。
|
|
/// 所有业务实体在此注册 DbSet。
|
|
/// 这是 Avalonia-API 和 Avalonia-PC 共用的具体数据上下文。
|
|
/// </summary>
|
|
public class AppDataContext(DatabaseConfiguration dbConfig) : AppDbContext(dbConfig)
|
|
{
|
|
/// <summary>天气预报数据</summary>
|
|
public DbSet<WeatherForecastEntity> WeatherForecasts => Set<WeatherForecastEntity>();
|
|
|
|
/// <summary>用户数据</summary>
|
|
public DbSet<UserEntity> Users => Set<UserEntity>();
|
|
|
|
/// <summary>API refresh token 数据</summary>
|
|
public DbSet<ApiRefreshTokenEntity> ApiRefreshTokens => Set<ApiRefreshTokenEntity>();
|
|
|
|
/// <summary>
|
|
/// 配置实体映射,包括主键、索引和属性约束。
|
|
/// </summary>
|
|
/// <param name="modelBuilder">模型构建器。</param>
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
modelBuilder.Entity<WeatherForecastEntity>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("pk-weather-forecast");
|
|
entity.Property(e => e.Summary).HasMaxLength(200);
|
|
});
|
|
|
|
modelBuilder.Entity<UserEntity>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("pk-user");
|
|
entity.Property(e => e.Email).HasMaxLength(200);
|
|
});
|
|
|
|
modelBuilder.Entity<ApiRefreshTokenEntity>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("pk-api-refresh-token");
|
|
entity.HasIndex(e => e.TokenHash).IsUnique().HasDatabaseName("idx-api-refresh-token-hash");
|
|
entity.HasIndex(e => e.UserId).HasDatabaseName("idx-api-refresh-token-user-id");
|
|
});
|
|
}
|
|
}
|
|
}
|