asp.net mvc model database change
I've used mvcScaffolding and mvc3 to generate my tables in a sql2008 database. some data has been added.
I've开发者_StackOverflow changed a single model and wish to alter the underlying table.
- is there a way to auto-update a single table to keep it in sync with the model?
- after adding a new model how can the database table be created without recreating the database
You're looking for something like Rails' migrations. There are a couple .NET migrations providers floating around, but the basic setup you've described doesn't support alterations to the schema without recreating the database (at least in my experience).
have you tried treating your database an an existing one as described in this example by Scott Gu?
http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx
Hopefully thias way you will not have to re-create your db everytime a change is required...
Regards
Paul
精彩评论