Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Entity Framework 4.1 Conventions

Are there any decent articles online that explain in detail how the conventions work in 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. 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?):

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.

like image 338
Brendan Vogt Avatar asked May 11 '11 07:05

Brendan Vogt


2 Answers

There is no real walkthrough. You can find basic description of all conventions in MSDN. My answer on MSDN forum posts links to all conventions.

There was really big change in conventions since 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. There is some mechanism (probably using reflection) which finds all defined sets in the contexts and starts mapping generation.

like image 121
Ladislav Mrnka Avatar answered Oct 25 '22 19:10

Ladislav Mrnka


A pretty good and simple explanation of Code First Conventions is available on MSDN, nicely titled: Code First Conventions.

like image 33
Gan Avatar answered Oct 25 '22 19:10

Gan