2

The documentation of Realm for Xamarin says:

Realm will automatically perform migrations that can be done without processing, like adding and removing classes or adding and removing properties from a class. For more complex changes, a proper migration is required. We do not yet have an API for this, but it is planned and will be added soon.

However, even when I just add a new field to a model, the app crash due to a required migration.

My question is: How can I make use of automatically performed migrations?

SushiHangover
  • 73,120
  • 10
  • 106
  • 165
Reynaldo Aguilar
  • 1,906
  • 1
  • 15
  • 29

2 Answers2

6

It is a known documentation issue: https://github.com/realm/realm-dotnet/issues/669

What you can do it is explicitly increment the schema version each time your simple model changes:

var config = RealmConfiguration.DefaultConfiguration;
config.SchemaVersion = 1;  // increment this when your model changes
SushiHangover
  • 73,120
  • 10
  • 106
  • 165
1

The answer by @SushiHangover is spot on. The documentation is still pending as we have had problems with our 0.77 release.

It is more of a protection than a limitation as it allows you to catch errors and prompt the user. Completely automatic migrations would make it a bit too easy to deploy code which made their files no longer backward compatible.

Andy Dent
  • 17,578
  • 6
  • 88
  • 115