diff --git a/src/YhCore.Repository/YHDbContext.cs b/src/YhCore.Repository/YHDbContext.cs index 986d811..2ce011f 100644 --- a/src/YhCore.Repository/YHDbContext.cs +++ b/src/YhCore.Repository/YHDbContext.cs @@ -80,15 +80,14 @@ namespace YhCore.Repository modelBuilder.Entity(clrType).HasNoKey(); } } - = // decimal 主键(多数表的 SerID)EF Core 约定不自增; // 若数据库对应列为 IDENTITY,需在此补充 ValueGeneratedOnAdd 配置。 // WY_DocPrint.SerID:旧 EF6 依赖数据库 IDENTITY 回填新增单据号,此处显式声明。 // WY_SHRole* / WY_DocPrint_SH / WY_DocPrint_Num / WY_reGetJERd / Common_Dictionary // 同属旧库 IDENTITY 列(旧代码新增时均不显式赋值 SerID),一并补充。 - // ⚠️ decimal 默认映射 decimal(18,2),scale≠0 的 IDENTITY 列 SQL Server 不允许(错误 2749), - // 必须显式声明 decimal(18,0)——否则 DatabaseInitializer 自动补表整批失败回滚。 + // ⚠️ decimal 默认映射 decimal(18,2),scale≠0 的 IDENTITY 列 SQL Server 不允许 + //(Msg 5720),必须显式声明 decimal(18,0)——否则自动补表整批失败回滚。 modelBuilder.Entity().Property(e => e.SerID).HasColumnType("decimal(18,0)").ValueGeneratedOnAdd(); modelBuilder.Entity().Property(e => e.SerID).HasColumnType("decimal(18,0)").ValueGeneratedOnAdd(); modelBuilder.Entity().Property(e => e.SerID).HasColumnType("decimal(18,0)").ValueGeneratedOnAdd();