Dave Paquette

Caffeine Driven Development

Entity Framework Presentations at Prairie Dev Con

May 7, 2013

Thanks to everyone who attended my Entity Framework presentations at Prairie Dev Con in Winnipeg.

Here are a few links to the sessions materials and some blog posts that explore some of the examples from the presentations:

Writing Efficient Queries with Entity Framework

Part 1  – Eager Loading

Part 2 – LINQ Projections

Part 3 – Paging

DbContext Lifetime

Managing your DbContext Lifetime in ASP.NET MVC4

Source code for Social Recipes

Get it on GitHub

Slides

Entity Framework Code First – Download

Code First Migrations – Download

Re-enabling Migrations? Use the Force, Richard

April 28, 2013

Whenever I do a presentation on Entity Framework Code First Migrations, I always take a moment to point out the helpful error messages provided by Entity Framework. In an industry plagued by nasty error codes and incomprehensible error messages, EF really stands out. It shows that the team took the time to provide helpful error messages. When something goes wrong in EF, the error message typically tell you what the problem was and what you can do to fix the problem. This isn’t always the case in EF, but they definitely have the most common errors covered off.

Here is an example of one of my favourite error messages from EF Code First:

The model backing the ‘xxContext’ context has changed since the database was created. Consider using Code First Migrations to update the database ( http://go.microsoft.com/fwlink/?LinkId=238269).

This message is perfect in so many ways. It tells me exactly what went wrong and provides the solution to the problem, complete with a link to a blog post with detailed instructions.

While Richard Reukema was presenting his SQL session at Windows Azure Boot Camp in Calgary yesterday, I found a new favourite EF error message:

Migrations have already been enabled in project ‘xx’. To overwrite the existing migrations configuration, use the -Force parameter.

Again, a well crafted error message explaining the problem and providing a solution. I fully endorse solution that involves “using the force”.  Well done EF team…well done.  (unless they mean use the negative force, in which case I revoke my endorsement)