Reputation: 720
I'm using VB.net, EF6 with SQL Server 2008R2 database.
This is the situation: I have created the application. Using wizard I have created the Entity model from an existing database.
A client started using this application using this database on his computer.
After some months, I made some modifications on the database and I have updated the model on my application.
Now I have a new .exe file that has the new model from the new database.
I put the new .exe file on the client computer.
Now on his computer, the .exe file has the new database model, but the SQL Server database has the old structure.
I want to know: is possible to update the database structure from the entity model on application?
I want to add a command on application that can make (if is possible) this update, so the database become up to date according to entity model?
Thank you !
Upvotes: 0
Views: 282
Reputation: 1514
If possible, try and deploy the database as a data-tier application. It will make managing migrations and upgrades a lot easier. More info here, https://msdn.microsoft.com/en-us/library/ee210546.aspx
Upvotes: 0
Reputation: 392
If you have applied code-first approach, then you should go for below solution , given on MSDN, so your generated script will be 'idempotent'.
Run the Update-Database -Script -SourceMigration: $InitialDatabase -TargetMigration: AddPostAbstract command in Package Manager Console
after going through it and still facing issue then try below command
Update-Database -Script -SourceMigration:0
Upvotes: 1