This project is read-only.

How to handle class changes?

Jan 19, 2014 at 8:15 PM
Hi,

I want to know how to handle changes on classes with ndatabase.
Example:
Property type changed from int to string.
or
classname has been changed ...

I got an exception, when I tried to open a database, which has an other class version than the current version.
(NDatabase has thrown an Exception Error:1002:Incompatible meta-model)

How to solve such things?
Is it possible to write a task to update these objects to the new version?
Jan 21, 2014 at 10:44 AM
You can use the IRefactorManager instance returned from the method:
var odb = OdbFactory.Open("your location");
var refactorManager = odb.GetRefactorManager();

it has methods to add, remove and rename fields and rename class.
Jan 21, 2014 at 9:15 PM
Thanks for the answer,

But this doesnt work for type changes of properties for example.
int --> string

It crashed at:
var database = OdbFactory.Open( DatabasePath );
(NDatabase has thrown an Exception Error:1002:Incompatible meta-model)

Because i have an object in the database with the old format.

I cant find any method for changes on the method signature beside the renaming.
Feb 1, 2014 at 1:59 PM
If it is not possible to update existing meta-models of data in the database,
caused by class changes described in my last post,
then ndatabase is unfortunately the wrong decision for continuing advancements of a software.
Jul 10, 2014 at 10:55 AM
Couldn't you write a class to migrate a database with old classes to a new database file with new classes? I know it's a bit of extra work to keep track of class changes through different versions of your software, but that might be a way to go.