Enums and Lookup Tables with EF Code First

With EntityFramework’s support for enums, there is no longer any need to include lookup tables in the model. But I do want to have them in the database for integrity, even with code first. I’ve been thinking for some time about to handle enums with code first. The idea behind code first is to be… Continue reading Enums and Lookup Tables with EF Code First

Code or Configuration or Configuration in Code?

With DevOps bringing source control to configuration files and publishing to production servers being automated – bringing both code and configuration over on the same time, the difference between code and config has become less than ever (if it even exists). A few weeks ago I reread Mike Hadlow’s brilliant post The Configuration Complexity Clock.… Continue reading Code or Configuration or Configuration in Code?

Merging Expression Trees to Reuse in Linq Queries

Reusing parts of LINQ queries is easily done by chaining methods returning IQueryable. Unfortunately that doesn’t cover some senarios like reusing member initialization lists. To handle such a situation I wrote a Merge extension method for select expressions. For this post we’ll load the data required for a list of cars and a detail view… Continue reading Merging Expression Trees to Reuse in Linq Queries

Make the DbContext Ambient with UnitOfWorkScope

The Entity Framework DbContext (or LINQ-to-SQL DataContext) is a Unit Of Work implementation. That means that the same DbContext should be used for all operations (both reading and writing) within a single web or service request. That means that there are a lot of different places where the DbContext have to be accessed. To avoid… Continue reading Make the DbContext Ambient with UnitOfWorkScope