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

Update-Database MSI Custom Action

In the Prevent EF Migrations from Creating or Changing the Database post I showed how to prevent the application from automatically creating or updating the database. Instead I want the installation program to do that. With a Web Setup Project for the installation an MSI Custom Action is needed. The actual work of updating the database is done… Continue reading Update-Database MSI Custom Action

EF Migrations Command Reference

Entity Framework Migrations are handled from the package manager console in Visual Studio. The usage is shown in various tutorials, but I haven’t found a complete list of the commands available and their usage, so I created my own. There are four available main commands. Enable-Migrations: Enables Code First Migrations in a project. Add-Migration: Scaffolds a migration… Continue reading EF Migrations Command Reference

Prevent EF Migrations from Creating or Changing the Database

One of the features of Entity Framework Code First is to automatically create the database on first access. It is a convenient approach in many cases. Unfortunately the applications I work with does not fall into one of those cases. The applications I develop typically run on a dedicated web server, with the database hosted… Continue reading Prevent EF Migrations from Creating or Changing the Database

EF Migrations and a Merge Conflict

To put a bit more stress on EF Migrations I’ll simulate a scenario that should be quite common in a multi developer environment. Developer A and B gets the latest code from the repository. Developer A adds a column and checks in a migration. Developer B adds another column and makes everything ready for checkin.… Continue reading EF Migrations and a Merge Conflict