Database updates in SmartStore.NET are done with the migration functionality of the Entity Framework
How to add a migration
Open the Nuget Package Manager Console:
Tools > Library Package Manager > Package Manager Console
Select SmartStore.Data as the default project and type
Now a c# class is automatically added to your solution within the SmartStore.Data project, which contains methods for upward and downward migrations. All changes that have been made to your domain classes are automatically added.
How to execute a migration
Once a migration has been added, it will be executed at the next start of the application. You can also run it via console by typing:
How to migrate locale resources
In order to migrate (add, update or delete) new locale string resources, you need to add the interface ILocaleResourcesProvider and IDataSeeder<SmartObjectContext> and implement their methods as follows:
How to migrate settings
In order to migrate setting entries, you also need to implement IDataSeeder<SmartObjectContext>. Then, you can add or delete your settings within the Seed method. You can even delete a whole group of settings.
How to add migrations to plugins
When you've changed the signature of one of your plugin specific domain entities, you first have to choose the build configuration EFMigrations before adding the migration to this project, otherwise Visual Studio won't find the correct path to the plugin assemblies.
You're able to migrate the plugin object context and the smartstore object context from a single migration. You just have to implement the IDataSeeder interface with both object contexts
How do I solve "No migrations configuration type was found in the assembly..."? Change the configuration to EFMigrations or set the nuget target manually. To do so, open the plugin project file with an editor and change the following line
How to downgrade
Sometimes it is necessary to run a migration twice or more often. However, once your migration has been executed, it won't be executed again. This also has to be managed via the console:
update-database -TargetMigration MyMigration
Now your database will be downgraded to the specified migration. Keep in mind that all other migrations that come in order after the specified migration will be rolled back too and all data that has already been added will be deleted and therefore lost.