Skip to content

Instantly share code, notes, and snippets.

@alexeyzimarev
Created February 16, 2017 13:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save alexeyzimarev/34542645ff8f27550d0679c7cb696111 to your computer and use it in GitHub Desktop.
namespace MassTransit.EntityFrameworkIntegration
{
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Infrastructure;
using System.Reflection;
public class AssemblyScanningSagaDbContext : DbContext
{
readonly Assembly _mappingAssembly;
public AssemblyScanningSagaDbContext(Assembly mappingAssembly, string nameOrConnectionString)
: base(nameOrConnectionString)
{
_mappingAssembly = mappingAssembly;
}
public AssemblyScanningSagaDbContext(Assembly mappingAssembly, ObjectContext objectContext, bool dbContextOwnsObjectContext)
: base(objectContext, dbContextOwnsObjectContext)
{
_mappingAssembly = mappingAssembly;
}
public AssemblyScanningSagaDbContext(Assembly mappingAssembly, DbConnection existingConnection, bool contextOwnsConnection)
: base(existingConnection, contextOwnsConnection)
{
_mappingAssembly = mappingAssembly;
}
public AssemblyScanningSagaDbContext(Assembly mappingAssembly, string nameOrConnectionString, DbCompiledModel model)
: base(nameOrConnectionString, model)
{
_mappingAssembly = mappingAssembly;
}
public AssemblyScanningSagaDbContext(Assembly mappingAssembly, DbConnection existingConnection, DbCompiledModel model, bool contextOwnsConnection)
: base(existingConnection, model, contextOwnsConnection)
{
_mappingAssembly = mappingAssembly;
}
protected AssemblyScanningSagaDbContext(Assembly mappingAssembly)
{
_mappingAssembly = mappingAssembly;
}
protected AssemblyScanningSagaDbContext(Assembly mappingAssembly, DbCompiledModel model)
: base(model)
{
_mappingAssembly = mappingAssembly;
}
protected override void OnModelCreating(DbModelBuilder modelBuilder) =>
modelBuilder.Configurations.AddFromAssembly(_mappingAssembly);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment