tags:

views:

51

answers:

1

Im using dbml (c# vs2010) to model my database and DataContext.CreateDatabase() to create it. Some time later I add a new property to one entity-type and now I want to upgrade the SQL-database to fit the new version of the dbml-schema. How do I accomplish this? Do I have to delete and re-create the database or upgrade it manually? Is ADO.NET EF better in this respect?

Update:

When searching for methods of updating the database according to changes in dbml I only get results for the inverse; updating dbml from changes in the database. But what is then the visual designer in dbml for? I want some master-design-view where I can do my changes and then generate sql-upgrade-script from that. Isnt that what everyone wants?

A: 

Neither Linq2Sql nor EF are made for this kind of scenario.

You asked if this is possible so in response to that I'll say that in theory I guess you could hack around this in EF by altering the schema of your db and using some script to alter the DBML file but I would highly recommend against it. Use the right tool for the job.

Sounds like ADO.NET might be a better solution for you.

statichippo
Im using ADO.NET EF4 now instead and it works much better with generating DDL-scripts for both creating and upgrading SQL-databases (with "Entity Designer Database Generation Power Pack").
Andreas Zita