sougatamondal / migratordotnet

Automatically exported from code.google.com/p/migratordotnet
0 stars 0 forks source link

Generate baseline migrations from NHibernate mapping filse #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
It may be useful for projects that use NHibernate to generate baseline 
BaselineMigration.cs files that would include all the code to generate the 
tables for initial creation.

A good deal of time is spent writing repetitive code to setup tables as 
they would appear at the beginning of the database refactoring model.

I believe there is some form of a SchemaExport in nhibernate. Perhaps it 
would be easier to use this to create a baseline from the mapping files. 
We wouldnt be able to rollback a migration, however I dont think anyone 
would ever need to rollback the database completely.

Original issue reported on code.google.com by dko...@gmail.com on 7 Jun 2008 at 11:51

GoogleCodeExporter commented 8 years ago
Would be real handy to do the same thing from EntityFramework also

Original comment by corey.do...@gmail.com on 15 Apr 2010 at 3:19

GoogleCodeExporter commented 8 years ago
I've recently just converted a project from using NHibernate's SchemaUpdate to 
using Migrator.NET.  The process was pretty straightforward; I basically just 
used SchemaExport to generate all the SQL that NHibernate wanted to use, and 
then rewrite that using Migrator.NET's syntax.  (A few more gyrations were 
required to preserve data across the transition and deal with people who 
started out with different versions of the database, but that didn't add too 
much complexity.)

What was a bit trickier was figuring out how NHibernate was generating its 
foreign key names, so that I could continue to use the same mechanism in order 
to still use SchemaUpdate as a sanity check (ie. if the migration code has 
updated to the latest version, then SchemaUpdate should generate zero lines of 
script.  If it generates more than that, then either the migrations or the 
mappings are wrong).

Original comment by uec...@gmail.com on 28 Jul 2010 at 3:22