Posted with : Studying
An easy and safe way to upgrate application's data
When upgrating an application to a newer version, it often requires to migrate its data (including delete/update some entities, add some new entities / configurations). At development phase, we often need to build some sample data for dev / test environments and reference data for production environment. DataUp comes to simplify this work, it was inspired by EF migrations & DbUp.
How to use
- Create a console application (or any kind if fit your need).
-
Console app is better as it’s easier for automation.
-
Add the package to your application’s references (DataUp on nuget.org)
- Create your data revision as a .NET class, implements the interface
IDataRevision
-
VersionNumber property is used to determine which revisions should be executed, small values first.
-
Execute method handles migration logic.
- Configuration
By convention, a connection string DataUp must be configured into .config file for DataUpContext.
In case of using the same database as the application, you must be aware that table Revisions will be used for DataUp.
<add name="DataUp" connectionString="server=.\SQLExpress;Database=App01DataUp;Integrated Security=True;" providerName="System.Data.SqlClient" />
Examples
DataV11 is a data revision example class, you can check the whole project there.
Requirements
DataUp is based on .NET 4.5 and EntityFramework 6.1.3.