在 .NET Core 3 下的 EF 中,我是否仍然需要一个明确的 N-to-N 中间实体?
Do I still need an explicit middle entity for N-to-N in EF under .NET Core 3?
我读过一些文章,例如 this one,其中暗示 A 和 B 之间必须有一个明确的实体 AB。
当我 google 这样做时,我找不到任何官方信息来证实或反驳该声明。另一方面,预览版的文档可能没有完全涵盖。
在 .NET Core 3 中是否可行,还是我们仍然被迫手动创建 N 对 N 实体?
是的,你需要实现中间实体!您可以使用以下命令进行检查:
dotnet ef dbcontext 脚手架 "Data Source=DATABASE_IP;Initial Catalog=NAMEDATABASE;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer -o 模型 -f -c DemoDbContext
#10508: Implement many-to-many relationships without mapping join table.
跟踪了您(不仅)要求的功能
如您所见,状态为Backlog
,表示正在考虑中,但没有具体的时间表。 EF Core 团队(经理)的 last comment 也是
Current plan for 3.0 is to implement skip-level navigation properties as a stretch goal. If property bags (#9914) also make it into 3.0, enabling a seamless experience for many-to-many could become easier.
也没有在 New features. And just referenced in Property bag entities
中列出
This feature is a stepping stone to support many-to-many relationships without a join entity (issue #1368), which is one of the most requested improvements for EF Core.
其中 #1368 指的是 Discussion on many-to-Many relationships (without CLR class for join table).
所有这些只是意味着您的问题的答案是 - 不,此功能不会出现在 3.0 中,因此您应该继续使用显式连接实体。
我读过一些文章,例如 this one,其中暗示 A 和 B 之间必须有一个明确的实体 AB。
当我 google 这样做时,我找不到任何官方信息来证实或反驳该声明。另一方面,预览版的文档可能没有完全涵盖。
在 .NET Core 3 中是否可行,还是我们仍然被迫手动创建 N 对 N 实体?
是的,你需要实现中间实体!您可以使用以下命令进行检查:
dotnet ef dbcontext 脚手架 "Data Source=DATABASE_IP;Initial Catalog=NAMEDATABASE;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer -o 模型 -f -c DemoDbContext
#10508: Implement many-to-many relationships without mapping join table.
跟踪了您(不仅)要求的功能如您所见,状态为Backlog
,表示正在考虑中,但没有具体的时间表。 EF Core 团队(经理)的 last comment 也是
Current plan for 3.0 is to implement skip-level navigation properties as a stretch goal. If property bags (#9914) also make it into 3.0, enabling a seamless experience for many-to-many could become easier.
也没有在 New features. And just referenced in Property bag entities
中列出This feature is a stepping stone to support many-to-many relationships without a join entity (issue #1368), which is one of the most requested improvements for EF Core.
其中 #1368 指的是 Discussion on many-to-Many relationships (without CLR class for join table).
所有这些只是意味着您的问题的答案是 - 不,此功能不会出现在 3.0 中,因此您应该继续使用显式连接实体。