GithubHelp home page GithubHelp logo

grinderofl / fluentmigrator.nhibernate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeffreyabecker/fluentmigrator.nhibernate

0.0 1.0 0.0 48 KB

A tool to generate FluentMigrator migrations from NHibernate.

License: MIT License

C# 100.00%

fluentmigrator.nhibernate's Introduction

FluentMigrator.NHibernate

A tool to generate FluentMigrator migrations from NHibernate.

Differences from EF Migrations

  • Entity Framework looks at its migration history table to find the most recently applied migrtation. FluentMigrator.NHibernate uses reflection against the assembly containing the migrations.
  • Entity Framework uses timestamps as migration numbers; FluentMigrator.NHibernate finds the last migration version in your assembly and increments.
  • You have a lot more control over the internals of how migrations are generated. FluentMigrator.NHiberate gives you an opportunity to override how the source & target expression lists are calcuated as well as an opportunity to filter expressions after the differences are calculated.

Usage

Right now there's no tooling for generating migrations akin to dotnet ef migrations .... Right now the most effective way to use the migration generator is to inherit from MigrationConfigurationBase, make sure to set MigrationNamespace and MigrationAssembly in the constructor, and over ride GetConfiguration to return your NHibernate configuration. In a unit test you can then call MyMigrationConfiguration.Generate("MigrationName","Path\To\MigrationsOutputFolder");.

public class MyNHibernateConfig : NHibernate.Cfg.Configuration
{
	public MyNHibernateConfig() : this("Data Source=(local);Database=myapp;Integrated Security=True;")
	{
		
	}
	public MyNHibernateConfig(string connectionString)
	{
		this.DataBaseIntegration(db =>
		{
			db.ConnectionString = connectionString;
			db.Dialect<MsSql2012Dialect>();
		});
		var mapper = new ConventionModelMapper();
		var mapping = mapper.CompileMappingFor(FindEntities());
		AddMapping(mapping);
	}

	private IEnumerable<Type> FindEntities()
	{
		return Enumerable.Empty<Type>();
	}
}
public class MyMigrationsConfiguration : MigrationConfigurationBase
{
	public MyMigrationsConfiguration()
	{
		MigrationAssembly = typeof (MyNHibernateConfig).Assembly;
		MigrationNamespace = "MyMigrationsApp.Domain.Db.Migrations";
	}

	protected override Configuration GetConfiguration()
	{
		return new MyNHibernateConfig();
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.