How to migrate data from old database to a new database?

Feb 12, 2015 at 6:48 PM
Edited Feb 12, 2015 at 6:49 PM
I'm working in an app and using NDatabase to store some simple data.

The problem is that when I release a new version of my software, sometimes I need to change the class, and that would make impossible to read existing database.

Example: Lets say that I have the following class:
Public Class Person()
   Dim Name as String
   Dim Age As Single
End Class
Now I want to release a new version of my app.
For some reason I need to change the type of Age to TimeSpan instead of single...
Then my new class is:
Public Class Person()
   Dim Name as String
   Dim Age As TimeSpan
End Class
How should I handle that situation ?
Because now all the old persisted data can't be read anymore cause the class fields changed.
Feb 12, 2015 at 7:05 PM
I was taking a look in the refactoring manager.
It seems to be the way to handle these issues...

But it also raises some questions...

What I understood is that I need to use the refactoring manager to perform these changes when I'm opening an old database.

Questions:

Q1:
How I know the database is outdated?
When I open a database it will throw exceptions if the fields don't match.

Q2:
How to manage multiple old versions?
If I have 3 different versions of databases out there...

Software V1.0
Public Class Person()
   Dim Name as String
   Dim Age As Double
End Class
Software V2.0
Public Class Person()
   Dim Name as String
   Dim Age As Single
End Class
Software V3.0
Public Class Person()
   Dim Name as String
   Dim Age As TimeSpan
End Class
How I control what changes should be done ?
Imagine that a person have downloaded the latest version (3.0) but he has his database in version 1.0.
How can I detect it ? I can create a field for version tracking... but before I want to know if there is an alternative.
Also if thats the case, I need to include refactoring for each version of database then... Right ?

Case v1.0...
Case v2.0...
and so on...