entity framework code first migration keep existing data
Asked Answered
B

1

13

I am using EF 6.1 and I use code first approach with an existing database with data in a production environment.

Is it possible at all to migrate model changes and keep the existing customer`s data?

Bag answered 1/5, 2014 at 20:21 Comment(2)
isn't that what migrations are for?Festal
What sort of model changes? Can you give an example? Code first doesn't require that you drop and recreate your db with every migrationSwigart
S
14

Yes, however, it can be complicated depending on specific case (on complexity of changes):

Overview: https://learn.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/existing-database

Read this: https://learn.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/index

And then this: https://learn.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/teams

Update: updated the links based on redirects.

Scrawl answered 1/5, 2014 at 20:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.