Petter Petter
Petter Petter

Reputation: 103

Changing the structure of my database / edmx model

I am using the edmx editor to create my database visually, but whenever I change the structure, and choose the option "Generate database from model", all my current data in the database is wiped.

Is it at all possible to change the structure of a database, and also retain the data?

How do people work around this problem?

Thank you

Upvotes: 0

Views: 30

Answers (1)

OJ Raqueño
OJ Raqueño

Reputation: 4561

Here are some solutions:

  1. Use the Code First or Database First workflow, as suggested in the comment to your question. Note: You can use Code First with an existing database.
  2. Maintain a data insert script which should be run after every "Generate database from model".
  3. Make the schema changes in your database first, then use "Update Model from Database" instead of "Generate database from model".

If using the Code First workflow is a possibility for you, I would recommend going that route.

Hope that helps.

Upvotes: 2

Related Questions