T. Webster
T. Webster

Reputation: 10109

Is Entity Framework Code First suited for this scenario?

I have some basic knowledge of Entity Framework 4.1 Code First, but haven't used this in a production application yet. I am in the architecture phase of a web app and have made no firm commitments to a DAL except that Entity Framework will be used. I have not decided which EF approach: Model First, Database First, or Code First. I was wondering how suitable Code First, or the other two, would be for this scenario. Which of the 3 approaches would work best?

Here is the scenario:

It would be great if you have had experience with a similar situation such as mine.

Upvotes: 0

Views: 278

Answers (1)

Slauma
Slauma

Reputation: 177163

Point 1 could be solvable by: Developer writes script, Developer gives script to DBA, DBA runs script :)

Point 2:

You don't need to drop the database in Code-First. The usual way in production is to switch off the database initializer (they are mainly meant for development phase only anyway):

Database.SetInitializer<MyContext>(null);

This way your application doesn't touch the database schema at runtime. You will get exceptions though if your model doesn't match the database schema anymore. To migrate to a new schema, you would have to change the schema manually or by scripts (give it to the DBA) to match your changes in the model.

For Database-First approach you have to do the same. And for Model-First too, I believe, because the scripts which Model-First creates by default start with dropping the existing database. None approach creates change scripts for you which only update an existing database schema. They always create the schema from scratch.

So, in my opinion the points you mentioned are not a reason to decide in favor or against Code-First.

Upvotes: 2

Related Questions