0

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 !

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

I have fist created the database on sql server management studio , and after from existing database through wizard I create the entity inside my application. It seems that I'm using Database first and not code first , or I'm wrong ? So if I'm using Database first , how can I use the solution ?
ok ,yes you are right, it seems you are using Database first approach. unfortunately there is no effective solution for migration for database first approach, try to generate a database script and give client to run in his database and it will work for client and so for you, too.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.