-
Notifications
You must be signed in to change notification settings - Fork 1
EfCore
LiZhengHao edited this page Jul 22, 2024
·
3 revisions
public class Model:EfEntity<long>
{
}
引入需要使用的雪花算法库,然后自己手动设置id值
public class CustomModel:EfEntity<int>,IEntityTypeConfiguration<CustomModel>
{
public string Category {get;set;}
public List<OtherModel> OtherModels{get;set;}
public void Configure(EntityTypeBuilder<AccuracyParameter> builder)
{
// 设置最大长度
builder.Property(it=>it.Category)
.HasMaxLength(-1);
// 多对多(不配置也可以,默认映射)
builder.HasMany<OtherModel>(x => x.OtherModels)
.WithMany(x => x.CustomModels);
}
}