控制实体框架中的参考?
在此处输入图像描述在实体框架中控制一个参考
opentity问题。
您认为什么是在MVC模式下工作的最有效方法,具有1个单一实体来引用本身。示例
public class ClassGroupAndSubgroup
{
public int ID { get; set; }
public int SubGroupId { get; set; }
public string Name{ get; set; }
}
ClassGroupAndSubgroup principalGroup { SubGroupId = 0, Name ="Principal"}; ----> Id = 1 (AutoNum)
ClassGroupAndSubgroup SubGroup { SubGroupId = 1, Name ="Item_1_Subgroup1"}; ----> Id = 2 (AutoNum)
ClassGroupAndSubgroup SubGroup_Two { SubGroupId = 1, Name ="Item_2_Subgroup1"}; ----> Id = 3 (AutoNum)
ClassGroupAndSubgroup principalGroup { SubGroupId = 3, Name ="Item_1_Subgroup2"};----> Id = 4 (AutoNum)
我想要的是自身进行引用,但要从EntityFramework Core中进行引用。很久以前,我用C#和SQL中的算法做到了,但我无法在实体中做到这一点
enter image description hereControl a reference in entity framework
Open question .Net Core 5 - Entities.
What do you think is the most efficient way to work in MVC mode, having 1 single entity that references itself. example
public class ClassGroupAndSubgroup
{
public int ID { get; set; }
public int SubGroupId { get; set; }
public string Name{ get; set; }
}
ClassGroupAndSubgroup principalGroup { SubGroupId = 0, Name ="Principal"}; ----> Id = 1 (AutoNum)
ClassGroupAndSubgroup SubGroup { SubGroupId = 1, Name ="Item_1_Subgroup1"}; ----> Id = 2 (AutoNum)
ClassGroupAndSubgroup SubGroup_Two { SubGroupId = 1, Name ="Item_2_Subgroup1"}; ----> Id = 3 (AutoNum)
ClassGroupAndSubgroup principalGroup { SubGroupId = 3, Name ="Item_1_Subgroup2"};----> Id = 4 (AutoNum)
What I want is to make reference on itself, but from EntityFramework Core. I did it a long time ago with algorithms in C# and SQL but I can't do it in entity
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您希望外键属性引用父项,而不是子项,例如
You want the Foreign Key property to refer to the parent, not the child, eg