Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can Entity Framework Migrations do that FluentMigrator cannot?

I have several databases currently using FluentMigrator and am curious to know how Entity Framework Migrations compare.

Can EF Migrations seed data in migrations and selectively run migration scripts based on environments like FluentMigrator can with tags and profiles?

I am already using EF Database First as the ORM to my application, and I think I read somewhere that EF Migrations are supported for non-Code First EF as well now, but my team has been thinking about refactoring to a Code First approach anyway because of some of the limitations with the Database First approach. So would EF Migrations just make more sense to use rather than have another 3rd party migration framework when going with a code first approach?

like image 366
Pam Avatar asked Aug 23 '13 15:08

Pam


Video Answer


2 Answers

Entity Framework automatically generates migration files and supports LINQ-to-SQL. FluentMigrations, in contrast, only scripts migrations and doesn't automatically generate migration files. FluentMigrations was developed several years before Entity Framework Code-First.

like image 82
Khelvaster Avatar answered Sep 19 '22 14:09

Khelvaster


I don't have any experience with FluentMigrator but after a brief skim of the documentation, it looks like you have to create your migrations manually?

EF will prompt for a migration every time your model changes and the app is run. This makes it kind of easy, but annoying at the same time. Once you've turned on Migrations, any changes to your model that would involve a database change will require a migration. You can modify the migration tho, and it's auto generated. Just watch the "down" version... I've had issues.

Code first is pretty seamless tho. Even handles more complex object models like subclasses. You can even specify how the tables are generated (table for each type, base table and a table for each type, or single table and a type key).

All that to say, if you're gonna always generate c# code to update your database, I'd go with EF's built in migrations. They do most of the work for you.

like image 23
Fred Avatar answered Sep 20 '22 14:09

Fred