首先是C#Entity Framework初始化类问题数据库 [英] C# Entity Framework initialization class problem database first

查看:144
本文介绍了首先是C#Entity Framework初始化类问题数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆