I have been using the model-first approach for about two weeks now and it works great. I also used the "Generate Database from Model" option, which results in a DDL being generated, which in turn is an SQL script that I run to create the database. If I add entities to my model and update the DDL it does not add an alter statement to entities that already exist, so if I were to run the script again it deletes previous tables and recreates them and deletes any data. Is there any way I can prevent this? Or do it differently? Or change my approach?
A:
Not really the DDL approach has two problems, and one is not really fixable:
As you found out it creates / recreates a database. No maintenance.
More important: It is stupid. As in: not smart. It can only use a very small but most common subset of what one can do in SQL Server, so it basically is only feasible for the most simplistic databases.
If you do not beliee the second point, read up the complete DDL for SQL Server in the documentation and be surprised how many things one can do for not so commen settings. All are transparent to the SQL UQuery side. And the vast majority of advanced features are not usable in EF4 DDL.
TomTom
2010-07-24 12:20:36
Thats disappointing, because now it means you have to get into the database intricasies
fr3dr1k8009
2010-07-26 06:21:26