【发布时间】:2020-02-08 21:59:45
【问题描述】:
我想将RoomLocation 类型的Location 映射到
Floor -> location_floor,
Building -> location_building,
Room -> location_room
Room.cs
public class Room
{
[Key]
public Guid Id { get; set; }
public string Title { get; set; }
public RoomLocation Location { get; set; }
public DateTime CreationDate { get; set; }
public DateTime ModificationDate { get; set; }
}
public class RoomLocation
{
public int Floor { get; set; }
public int Building { get; set; }
public int Room { get; set; }
}
数据库图
注意:在一个较旧的项目中,我忘记添加builder.HasKey,它确实有效我查看了日志,Entity Framework 现在将查询转换为user_,因为我忘记了到底发生了什么我无法重做这种情况.
我正在使用带有 Npgsql 的实体框架和 SnakeCaseNamingConvention。
【问题讨论】:
-
只是为了确定,您使用的是 EF Core(哪个版本?),EFCore.NamingConventions?如果是这样,您到底遇到了什么问题?
-
@ShayRojansky 版本
3.1.1.2和EFCore.NamingConventions,我希望将Location与它的属性映射到蛇盒,例如Location.Floor到location_floor。
标签: asp.net postgresql entity-framework-core npgsql