Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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