首先是C#Entity Framework初始化类问题数据库 [英] C# Entity Framework initialization class problem database first
问题描述
Hello
Hello
我的问题是:我从一个带有2个表的数据库生成了一个edmx实体框架。这两个表具有1-N关系。然后,实体框架生成第一个实体(EntityA) 与
a costructor初始化 与第二个实体(EntityB)相关联的HashSet。
My problem is: I've generated an edmx entity framework from a database with 2 tables. These 2 tables have 1-N relation. Then the Entity Framework generates the first entity (EntityA) with a costructor which initialize an HashSet associated with the second entity (EntityB).
我的问题是:我需要初始化EntityA的部分或全部属性,所以我考虑使用部分类EntityA。在这个部分类中,我无法定义构造函数,因为已经在实体框架中的自动生成的分部类中定义了它。
My question is: I need to initialize some or all attributes of EntityA, so I thought about using a partial class EntityA. In this partial class I cannot define the constructor because is already defined in the autogenerated partial class from entity framework.
如何初始化变量?请帮助我!
How can I initialize variables? Please help me!
谢谢
Matteo
Matteo
推荐答案
你好
我的问题是:我从具有2个表的数据库生成了一个edmx实体框架。这两个表具有1-N关系。然后,实体框架生成第一个实体(EntityA) ,其中包含一个初始化
与第二个实体(EntityB)关联的HashSet的costructor。
My problem is: I've generated an edmx entity framework from a database with 2 tables. These 2 tables have 1-N relation. Then the Entity Framework generates the first entity (EntityA) with a costructor which initialize an HashSet associated with the second entity (EntityB).
我的问题是:我需要初始化EntityA的部分或全部属性,所以我考虑使用部分类EntityA。在这个部分类中,我无法定义构造函数,因为已经在实体框架中的自动生成的部分类中定义了它。
My question is: I need to initialize some or all attributes of EntityA, so I thought about using a partial class EntityA. In this partial class I cannot define the constructor because is already defined in the autogenerated partial class from entity framework.
如何初始化变量?请帮助我!
How can I initialize variables? Please help me!
谢谢
Matteo
这篇关于首先是C#Entity Framework初始化类问题数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!