资 源 简 介
Making changes to a database schema or its data requires careful planning and execution, to avoid mistakes.
This library provides support for this task, allowing the user to write update scripts once, save them in a common location, with logical naming, and apply them easily.
Support for storing migration scripts in a .NET assembly and applying them to an SQL Server database is built in. The architecture caters for those wishing to add support for other forms of migration storage or database provider.
```
var db = new SqlVersionedDb(connection);
decimal version = db.Version();
if (version == Constants.Unversioned)
log.WriteLine("Creating database.");
else
log.WriteLine(string.Format("Initial database version: {0}", version);
db.beginningUpdate +=
index => log.Write(string.Format("Updating to version: {0} ... ", index));
db.updateComplete +=
(index, successful, message) =>
{
if (successful)
{