实体框架:将字典映射到表 [英] Entity Framework: Map dictionary to a table

查看:93
本文介绍了实体框架:将字典映射到表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须处理数据库,其中新表不断添加以表示一些


users

推荐答案

Wm92

我不确定我完全理解你,但我会尝试回答,实体框架有3种数据库操作策略代码优先方法,模型第一种方法而不是误解数据库 首先,我已经  ;使用   首先
 两个数据库方法除外,要先将字段(列)映射为关键代码,首先要求您实现System.Serialization.DataAnotations,他会向您展示实体映射属性,如启用列
index和Keys属性,如果您使用模型优先方法,则可以直接在edmx文件UI上设置这些属性。有很多方法可以实现您的存储库,您可以在字典中映射实体,只要
您了解.Net就没关系。您问题的主要混淆部分是声明'键是列'名称'?你是吗?引用表键或字典键?

I am not sure I understand you fully , but I will attempt to answer , entity framework has 3 database manipulation strategies code-first approach , model first approach and not mistaking database first , I have  used  the first  two except Database approach , to map a field (column) as a key code first implement require you to place an implementation of System.Serialization.DataAnotations , his will expose you to the entity mapping properties like enabling column index's and Keys property's if you are using model first approach you can setup those properties directly on the edmx file UI . there are many ways  to implement you repository you can map entities in dictionaries it doesn't matter as long as you understand .Net . the main confusing part of your question is on statement 'keys are columns' names' ? are you  referring to table keys , or the dictionary key ?

字典也可以包含表格(实体)和实际表格(实体)为()=>

also a dictionary can contain both table (entity) key and the actual table (entity) as ()=>

字典< INT,人> personDC = new Dictionary< int,Person>(),使得key是table(entity)Person的主键。

Dictionary<int,Person> personDC=new Dictionary<int,Person>() such that key is the primary key of table(entity) Person.


这篇关于实体框架:将字典映射到表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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