c# - 在 EF Core 3.1 中替换 Map() 的最佳方法是什么
问题描述
我已经将EntityFramework 6的项目实现到EntityFramework Core 3.1中。使用 Roslyn API,我必须将实体映射到实体框架中的表。我对此一无所知。
示例.cs
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Student>().Map(m =>
{
m.Properties(p => new { p.StudentId, p.StudentName});
m.ToTable("StudentInfo");
}).Map(m => {
m.Properties(p => new
{ p.StudentId, p.Height, p.Weight, p.Photo, p.DateOfBirth});
m.ToTable("StudentInfoDetail");
});
modelBuilder.Entity<Standard>().ToTable("StandardInfo");
}
建议基于堆栈溢出链接,EF 核心不再支持。参考:EF Core 2.0 中的一个实体 2 表
请就此提出替代解决方案以及如何在 Roslyn API 中执行建议?
解决方案
推荐阅读
- c++ - 'new' 和 'delete' 在 C++ 中被弃用了吗?
- java - Spring Boot 获取 application.properties (或其文件路径)的距离
- java - 无法在视频视图android中播放视频表单网址
- excel - Excel 的链接在 Powerpoint 中中断
- java - 在 Hybris 的 itemtype 中使用扩展
- excel - CountIf 索引匹配标记唯一
- isabelle - 在 Isabelle/HOL 中未定义
- python - 计算忽略nans的pandas数据框列的一部分的平均值
- javascript - 使用 javascript / jquery 在日期输入中手动移动到年/月/日
- android - 如何滚动到 RecyclerView 中的视图内的 EditText 并将其聚焦?