<Project Sdk="Microsoft.NET.Sdk.Web">
<ItemGroup>
<PackageReference Include="Known.EntityFramework" Version="1.0.5" />
<!--还需要添加EFCore的数据库依赖,此处以SqlServer为例-->
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
</ItemGroup>
</Project>
builder.Services.AddKnownEntityFramework(option =>
{
// 配置数据库
option.OnConfig = c => c.UseSqlServer(builder.Configuration.GetSection("ConnString").Get<string>());
// 在此配置业务库数据模型
option.OnModel = m =>
{
m.Entity<YourEntity>().HasKey(x => x.Id);
};
});