简体   繁体   English

了解实体框架4.1约定

[英]Understanding Entity Framework 4.1 Conventions

Are there any decent articles online that explain in detail how the conventions work in EF 4.1? 在线是否有任何体面的文章详细解释了这些约定在EF 4.1中的作用? There was an article linked from Scott Gu's blog, but it was dated 2010, I think it was then in CTP 4. Not sure if the conventions have beem modified since then. 有一篇文章链接自Scott Gu的博客,但是它的日期是2010年,我认为那是在CTP 4中。不确定这些约定是否已经被修改过。 But I don't understand how it works. 但我不明白它是如何工作的。 For example how does it know to use the table SkillType if I have this code (what does it look for?): 例如,如果我有这个代码,它如何知道使用表SkillType(它寻找什么?):

public DbSet<SkillType> SkillTypes { get; set; }

This is just 1 of my confusions, then there is foreign keys, primary keys, etc. I need to familiarise myself with these conventions so any goof articles that I can read please let me know. 这只是我的一个混乱,然后有外键,主键等。我需要熟悉这些约定,所以我能阅读的任何蠢文都请告诉我。 I did Google and couldn't get anything solid and concrete. 我做了谷歌,并没有得到任何坚实和具体的东西。

There is no real walkthrough. 没有真正的演练。 You can find basic description of all conventions in MSDN. 您可以在MSDN中找到所有约定的基本描述。 My answer on MSDN forum posts links to all conventions. 我在MSDN论坛帖子上的答案链接到所有约定。

There was really big change in conventions since CTP5. 自CTP5以来,惯例发生了很大的变化。 First of all you cannot add custom conventions any more - this feature was removed from final version. 首先,您无法再添加自定义约定 - 此功能已从最终版本中删除。 If you define DbSet as in your example it is not job for convention to define table. 如果您在示例中定义DbSet ,则定义表的约定不是作业。 There is some mechanism (probably using reflection) which finds all defined sets in the contexts and starts mapping generation. 有一些机制(可能使用反射)在上下文中查找所有已定义的集合并开始映射生成。

MSDN上提供了对Code First Conventions的一个非常好的简单解释,标题为: Code First Conventions

I also like and recommend ADO.Net team blog :) 我也喜欢并推荐ADO.Net团队博客:)

http://blogs.msdn.com/b/adonet/ http://blogs.msdn.com/b/adonet/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM