Utility to import/export data in SQLServer
We have built an desktop(windows) application that needs SQL Server to store the data. Now if we do any changes on database side, we need to backup the database of user's application, amend our changes and restore it back to user's application.
We have written code to backup & restore the .bak file in the application that works fine.
But now we need to build an online utility where user could upload the data file, then our changes could ammend and then they could download the update data to restore.
Please suggest me some ideas to implement this feature.
P.S.: I have posted the question in the zone where i felt it was correct. Please change to appropriate zone (i开发者_运维技巧f required)
thanks!
Write migrations with Migrator.NET to update your schema and deploy schema changes as a runnable update to your clients.
Here is an example from the Getting Started documentation:
using Migrator.Framework;
using System.Data;
namespace DBMigration
{
[Migration(20080401110402)]
public class CreateUserTable_001 : Migration
{
public void Up()
{
Database.CreateTable("User",
new Column("UserId", DbType.Int32, ColumnProperties.PrimaryKeyWithIdentity),
new Column("Username", DbType.AnsiString, 25)
);
}
public void Down()
{
Database.RemoveTable("User");
}
}
}
There are nice wrappers for adding/removing columns, but you can execute any arbitrary SQL.
Why not provide your user the script that they can run (or you provide it as a part of setup or have a simple utility to run the script) on the database to apply the changes.
Typically, as you make database side changes at your dev environment, generate scripts for the same and maintain them till you release the new version of your application.
精彩评论