jeudi 21 janvier 2016

SQLite code-first onModelCahnge how to keep the old data from databse

i'm new to Sqlite and EF.

i created a DbContext with some model classes which will create a local database on app start. Database will get updated while application running.

When i change something in model (ex: add new property to a class) and run the application, the whole database is recreating from scratch. so i'm loosing my saved data.

How can i keep the old data even though the model changes.

For Ex:

Database.table1
ID | Name
1  | abc
2  | xyz

when i add new prop to table1 class, its recreating table with empty data, where i need something like this if possible.

Database.table1
ID | Name | NewProp
1  | abc  | Null
2  | xyz  | Null

Aucun commentaire:

Enregistrer un commentaire