Friday, April 27, 2012

Avoid EF code first

Entity Framework 41 introduces “code-first” which will infer a database design from your plain old CLR objects (POCO). It’s a nice idea, but doesn’t handle changes to the model well. You either have to do them manually (which means learning how it maps POCOs to tables, etc) or let it drop and recreate an empty database.

That’s fine for tests, demos and toy systems, but no use for anything serious. Personally I prefer the database-first approach where I can create my tables and define referential integrity constraints then then have EF create the data model objects for me.

This side-steps the drop-and-recreate issue as I can choose to add columns and keep my data.

No comments: