开发者

Is there something like ActiveRecord::Migration for .NET?

开发者 https://www.devze.com 2023-02-15 02:45 出处:网络
I\'ve played around with ruby on rails\' ActiveRecord::Migration class and I like how easy it is to keep database schemas versioned. I want to do something similar in my ASP.NET project and I\'m wonde

I've played around with ruby on rails' ActiveRecord::Migration class and I like how easy it is to keep database schemas versioned. I want to do something similar in my ASP.NET project and I'm wondering if anyone has heard of a tool that does what ActiveRecord::Migration does but for .NET.

I don't see the need of defining my SQL scripts in C# or ruby code, I just want to write SQL. But i开发者_运维知识库s there a tool that manages SQL scripts and keeps track of what scripts you need to run to get in sync?


migratordotnet is a database versioning system much like Ruby on Rail's Migrations. Its purpose is to automate your database changes, and help keep those changes in sync throughout your environments.


Here's one that focuses on cross database compatibility: https://github.com/dradovic/MigSharp/wiki/Feature-Overview

Write your migration once, and let them run on different platforms.


Database projects in Visual Studio have the features that you need. You can do schema comparisons to keep track of the differences between schema versions. They can also handle deployment, although your deployment needs may differ.

Database Projects @ MSDN

There are also other 3rd party tools that may be used as well, such as SQL Compare by Redgate.

SQL Compare by Redgate

Added:

Unfortunately, neither of these has intrinsic support for git. But, this wouldn't prevent you from bridging the gap if you don't mind doing most of the work yourself.

With Visual Studio, you can use MSBuild to automatically run scripts/executables associated with compile actions. From there, you could attach your own interactions with git.

MSBuild Reference @ MSDN

If you're looking for a tool that can automatically deploy a schema change from git, I don't know of any that exist at this time; but you could roll your own using SMO. It has all the functionality you need to be able to script SQL Server objects and execute scripts against SQL Server. You will probably have to do your own incremental scripts for table changes (as a matter of safety), but you could do drop/replace for many other objects that aren't data (Stored Procedures, User Functions, etc.).

SQL Server Management Objects @ MSDN


Red Gate is considering a migrations feature which will integrate with SQL Source Control and SQL Compare. If you're interested in this, please consider filling in our research survey and let us know what your requirements are. Filling the survey will also entitle you to join our early access program.

http://www.surveymk.com/s/migrations

0

精彩评论

暂无评论...
验证码 换一张
取 消