public virtual void FixtureSetup() { OrdersContextProvider = () => { var orderEntities = new OrderEntities(); orderEntities.ContextOptions.LazyLoadingEnabled = true; return orderEntities; }; HRContextProvider = () => { var hrEntities = new HREntities(); hrEntities.ContextOptions.LazyLoadingEnabled = true; return hrEntities; }; UnitOfWorkFactory = new EFUnitOfWorkFactory(); UnitOfWorkFactory.RegisterContextProvider(HRContextProvider); UnitOfWorkFactory.RegisterContextProvider(OrdersContextProvider); Locator = MockRepository.GenerateStub<IServiceLocator>(); Locator.Stub(x => x.GetInstance<IUnitOfWorkFactory>()).Return(UnitOfWorkFactory); Locator.Stub(x => x.GetInstance<IState>()).Do(new Func<IState>(() => State)); ServiceLocator.SetLocatorProvider(() => Locator); }
protected void Application_Start() { //// Setup StructureMap to determine the concrete repository pattern to use. //ObjectFactory.Initialize( // x => // { // x.For<IUnitOfWorkFactory>().Use<EFUnitOfWorkFactory>(); // x.For(typeof(IRepository<>)).Use(typeof(Repository<>)); // } //); /*Moved to dependencyResolution IoC.cs*/ // Select an Entity Framework model to use with the factory. EFUnitOfWorkFactory.SetObjectContext(() => new DataShareContext()); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); //Never recreate the database Database.SetInitializer <DataShareContext>(null); #if DEBUG //track LINQ queries executed using entity FrameworkProfiler HibernatingRhinos.Profiler.Appender.EntityFramework.EntityFrameworkProfiler.Initialize(); #endif var sqlUtility = new DS.Service.SqlTableUtility(); sqlUtility.DropTables(sqlUtility.GetUnusedDSTables()); sqlUtility = null; }
public void EmailAddressTypeRoundtipsToDatabase() { int newPersonId = 0; ContactType type = ContactType.Personal; var address = CreateEmailAddress(); address.ContactType = type; Person person = SimplePeopleTests.CreatePerson(); person.EmailAddresses.Add(address); using (var uwo = new EFUnitOfWorkFactory().Create()) { PeopleRepository peopleRepository = new PeopleRepository(); peopleRepository.Add(person); } newPersonId = person.Id; newPersonId.Should().BeGreaterThan(0); ContactManagerContext context = new ContactManagerContext(); var check = context.People.Include("EmailAddresses").First(x => x.Id == newPersonId); check.Id.Should().Be(newPersonId); check.EmailAddresses.First().ContactType.Should().Be(type); }
public void SetUp() { EFUnitOfWorkFactory.SetObjectContextProvider(() => { var context = new SugiBpmContext(); return(context); }); var builder = new ContainerBuilder(); builder.RegisterType <EFUnitOfWorkFactory>().As <IUnitOfWorkFactory>(); builder.RegisterType <EFRepository <ActionDef> >().As <IRepository <ActionDef> >(); builder.RegisterType <EFRepository <Transition> >().As <IRepository <Transition> >(); builder.RegisterType <EFRepository <ProcessBlock> >().As <IRepository <ProcessBlock> >(); builder.RegisterType <EFRepository <Flow> >().As <IRepository <Flow> >(); builder.RegisterType <EFRepository <DelegationDef> >().As <IRepository <DelegationDef> >(); builder.RegisterType <EFRepository <Actor> >().As <IRepository <Actor> >(); builder.RegisterType <FakeDelegationHelper>().As <IDelegationHelper>(); builder.RegisterType <OrganizationApplication>().As <IOrganizationApplication>(); var container = builder.Build(); Autofac.Extras.CommonServiceLocator.AutofacServiceLocator serviceLocator = new Autofac.Extras.CommonServiceLocator.AutofacServiceLocator(container); ServiceLocator.SetLocatorProvider(() => serviceLocator); }
public void Create_Throws_InvalidOperationException_When_No_DataContextProvider_Has_Been_Set() { var factory = new EFUnitOfWorkFactory(); Assert.Throws<InvalidOperationException>( () => factory.Create() ); }
public void FindByWithIncludeReturnsOnlyIncludedAndNotOtherProperties() { var phoneNumber1 = new PhoneNumber { ContactType = ContactType.Business, Number = "555-12345678" }; var phoneNumber2 = new PhoneNumber { ContactType = ContactType.Business, Number = "555-12345678" }; var emailAddress1 = EmailAddressTests.CreateEmailAddress(); var emailAddress2 = EmailAddressTests.CreateEmailAddress(); Person person = CreatePerson(); person.PhoneNumbers.Add(phoneNumber1); person.PhoneNumbers.Add(phoneNumber2); person.EmailAddresses.Add(emailAddress1); person.EmailAddresses.Add(emailAddress2); using (var uow = new EFUnitOfWorkFactory().Create()) { var peopleRepository = new PeopleRepository(); peopleRepository.Add(person); } using (var uow = new EFUnitOfWorkFactory().Create(true)) { var peopleRepository = new PeopleRepository(); var check = peopleRepository.FindById(person.Id, x => x.PhoneNumbers); check.PhoneNumbers.Count.Should().Be(2); check.EmailAddresses.Count.Should().Be(0); } }
public void FixtureSetup() { this.unityContainer = new UnityContainer(); IoC.Initialize( (x, y) => this.unityContainer.RegisterType(x, y), (x, y) => this.unityContainer.RegisterInstance(x, y), (x) => { return(unityContainer.Resolve(x)); }, (x) => { return(unityContainer.ResolveAll(x)); }); // Context Factory EFUnitOfWorkFactory ctxFactory = new EFUnitOfWorkFactory(this.ConnectionString(), typeof(DomainContext)); if (!ctxFactory.DatabaseExists()) { ctxFactory.CreateDatabase(); } ctxFactory.ValidateDatabaseSchema(); this.unityContainer.RegisterInstance <IDatabaseManager>(ctxFactory); this.unityContainer.RegisterInstance <IUnitOfWorkFactory>(ctxFactory); this.unityContainer.RegisterType <DbContext, DomainContext>(new InjectionFactory((c) => { return(ctxFactory.CurrentDbContext); })); // Repositories this.unityContainer.RegisterType <IEntityARepository, EntityAEFRepository>(new PerResolveLifetimeManager()); this.unityContainer.RegisterType <IEntityBRepository, EntityBEFRepository>(new PerResolveLifetimeManager()); ApplicationContext.User = new CorePrincipal(new CoreIdentity("cmendible", "hexa.auth", "*****@*****.**"), new string[] { }); }
public virtual void FixtureSetup() { OrdersContextProvider = () => { var orderEntities = new OrderEntities(); orderEntities.ContextOptions.LazyLoadingEnabled = true; return(orderEntities); }; HRContextProvider = () => { var hrEntities = new HREntities(); hrEntities.ContextOptions.LazyLoadingEnabled = true; return(hrEntities); }; UnitOfWorkFactory = new EFUnitOfWorkFactory(); UnitOfWorkFactory.RegisterContextProvider(HRContextProvider); UnitOfWorkFactory.RegisterContextProvider(OrdersContextProvider); Locator = MockRepository.GenerateStub <IServiceLocator>(); Locator.Stub(x => x.GetInstance <IUnitOfWorkFactory>()).Return(UnitOfWorkFactory); Locator.Stub(x => x.GetInstance <IState>()).Do(new Func <IState>(() => State)); ServiceLocator.SetLocatorProvider(() => Locator); }
public void Create_Throws_InvalidOperationException_When_No_DataContextProvider_Has_Been_Set() { var factory = new EFUnitOfWorkFactory(); Assert.Throws <InvalidOperationException>( () => factory.Create() ); }
public static void ConfigureContextProvider() { EFUnitOfWorkFactory.SetObjectContextProvider(() => { var context = new SugiBpmContext(); return(context); }); }
public void Create_Returns_NHUnitOfWork_Instance_When_SessionFactoryProvider_Has_Been_Set() { var factory = new EFUnitOfWorkFactory(); factory.RegisterContextProvider(() => new OrderEntities()); var uowInstance = factory.Create(); Assert.That(uowInstance, Is.Not.Null); Assert.That(uowInstance, Is.TypeOf(typeof(EFUnitOfWork))); }
static void Main(string[] args) { if (args.Length == 1) { _fileName = args[0]; } using (var engine = new FileHelperAsyncEngine <ImportPerson>()) { engine.BeginReadFile(_fileName); int success = 0; int failed = 0; var stopwatch = new Stopwatch(); stopwatch.Start(); using (var uow = new EFUnitOfWorkFactory().Create()) { foreach (ImportPerson importPerson in engine) { try { var person = new Person(); Mapper.Map(importPerson, person); TryAddEmailAddress(importPerson, person); TryAddPhoneNumber(importPerson, person); person.HomeAddress = FixAddress(person.HomeAddress, changeMissingDataToNull: false); // False sets missing data to <unknown>. person.WorkAddress = FixAddress(person.WorkAddress, changeMissingDataToNull: false); // False sets missing data to <unknown>. if (!person.Validate().Any()) { success++; PeopleRepository.Add(person); if (success % 30 == 0) { uow.Commit(true); } } else { //TODO Handle invalid data. Log it, or deal with it in some way. failed++; } } catch (Exception ex) { //TODO Handle error. Log it, or deal with it in some way. Console.WriteLine("Failed to import row " + engine.LineNumber); Console.WriteLine("Error " + ex.Message); failed++; } long elapsed = stopwatch.ElapsedMilliseconds; double timeForOne = (elapsed / (double)success) / 1000; double perSecond = 1 / timeForOne; UpdateUI(success, failed, elapsed, perSecond, importPerson); } } stopwatch.Stop(); engine.Close(); } }
public static void RegisterComponents() { var container = new UnityContainer(); container.RegisterType <IUnitOfWorkFactory, EFUnitOfWorkFactory>(); container.RegisterType(typeof(IRepository <>), typeof(EFRepository <>)); EFUnitOfWorkFactory.SetObjectContext(() => new Entities()); container.LoadConfiguration(); DependencyResolver.SetResolver(new Unity.Mvc5.UnityDependencyResolver(container)); //unity for mvc controllers }
public virtual void FixtureSetup() { _unitOfWorkFactory = new EFUnitOfWorkFactory(); _unitOfWorkFactory.RegisterContextProvider(() => new CodeOnlyContext("SandboxCodeOnly").Context); Locator = MockRepository.GenerateStub <IServiceLocator>(); Locator.Stub(x => x.GetInstance <IUnitOfWorkFactory>()).Return(_unitOfWorkFactory); Locator.Stub(x => x.GetInstance <IState>()).Do(new Func <IState>(() => State)); ServiceLocator.SetLocatorProvider(() => Locator); }
public void Setup() { UnitOfWork = new EFUnitOfWorkFactory( new TrainingTaskDbContext(new DbContextOptionsBuilder <TrainingTaskDbContext>() .UseSqlServer( "Data Source=QWS-PFR-10;Initial Catalog=TrainingTaskDb;User ID=ttuser;Password=ttuser;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" ).Options ), new MapperConfiguration(opt => opt.AddMaps(AppDomain.CurrentDomain.GetAssemblies())).CreateMapper()) .CreateUnitOfWork(); }
static void Main(string[] args) { IUnitOfWorkFactory uwf = new EFUnitOfWorkFactory(); ITerminal terminal = new VT100(); IPurchaseOrderService purchaseOrderService = new PurchaseOrderService(uwf); PurchaseOrderScreen screen = new PurchaseOrderScreen(purchaseOrderService, terminal); screen.Display(); }
public virtual void FixtureSetup() { _unitOfWorkFactory = new EFUnitOfWorkFactory(); ConnectionString = ConfigurationManager.ConnectionStrings["Sandbox"].ConnectionString; _unitOfWorkFactory.RegisterContextProvider(() => new PocoContext(ConnectionString)); Locator = MockRepository.GenerateStub <IServiceLocator>(); Locator.Stub(x => x.GetInstance <IUnitOfWorkFactory>()).Return(_unitOfWorkFactory); Locator.Stub(x => x.GetInstance <IState>()).Do(new Func <IState>(() => State)); ServiceLocator.SetLocatorProvider(() => Locator); }
public void Create_Returns_LinqToSqlUnitOfWork_Instance_When_DataContextProvider_Has_Been_Set() { EFUnitOfWorkFactory.SetObjectContextProvider(() => new TestModel()); var factory = new EFUnitOfWorkFactory(); var uowInstance = factory.Create(); Assert.That(uowInstance, Is.Not.Null); Assert.That(uowInstance, Is.TypeOf(typeof(EFUnitOfWork))); EFUnitOfWorkFactory.SetObjectContextProvider(null); }
public PresupuestoRepositoryTests() { var ambientDbContextLocator = new AmbientDbContextLocator(); uowFactory = new EFUnitOfWorkFactory(System.Data.IsolationLevel.ReadCommitted); repository = new PresupuestoRepository(ambientDbContextLocator); clienteRepository = new ClienteRepository(ambientDbContextLocator); vehiculoRepository = new VehiculoRepository(ambientDbContextLocator); cliente = new Cliente("Carlos", "Tirado", "941", true); vehiculo = new Vehiculo("Opel", "Astra", 200); cliente2 = new Cliente("Juan", "Pérez", "941", false); vehiculo2 = new Vehiculo("Reanult", "Megane", 210); }
public void ValidationErrorsThrowModelValidationException() { var uow = new EFUnitOfWorkFactory().Create(); Action act = () => { var repo = new PeopleRepository(); repo.Add(new Person()); uow.Commit(true); }; act.ShouldThrow <ModelValidationException>().WithMessage("The FirstName field is required", ComparisonMode.Substring); uow.Undo(); }
public void Test_Holiday_Update_From_Url() { string url = "http://data.ntpc.gov.tw/api/v1/rest/datastore/382000000A-000077-002"; ISourceGraber <SourceHoliday> sourceGraber = new HttpSourceGraber <SourceHoliday>(url); IUnitOfWork unitOfWork = EFUnitOfWorkFactory.GetUnitOfWork <HolidayEntities>(); IGenericDataAccess <TWHoliday> dataAccess = new GenericDataAccess <TWHoliday>(unitOfWork); HolidayMaintainer maintanier = new HolidayMaintainer(sourceGraber, dataAccess); var source = maintanier.AddHolidayFromSource(); Assert.AreEqual(true, source); }
public static void Initialize() { // Hook up the interception ObjectFactory.Initialize( x => { x.ForRequestedType <IUnitOfWorkFactory>().TheDefaultIsConcreteType <EFUnitOfWorkFactory>(); x.ForRequestedType(typeof(IRepository <>)).TheDefaultIsConcreteType(typeof(EFRepository <>)); } ); // We tell the concrete factory what EF model we want to use EFUnitOfWorkFactory.SetObjectContext(() => new ALSIEntities()); }
public void SetUp() { EFUnitOfWorkFactory.SetObjectContextProvider(() => { var context = new TestModel(); return(context); }); var locator = MockRepository.GenerateStub <IServiceLocator>(); locator.Stub(x => x.GetInstance <IUnitOfWorkFactory>()) .Return(new EFUnitOfWorkFactory()).Repeat.Any(); ServiceLocator.SetLocatorProvider(() => locator); }
public DataShareService() { // Setup StructureMap to determine the concrete repository pattern to use. ObjectFactory.Initialize( x => { x.For <IUnitOfWorkFactory>().Use <EFUnitOfWorkFactory>(); x.For(typeof(IRepository <>)).Use(typeof(Repository <>)); } ); // Select an Entity Framework model to use with the factory. EFUnitOfWorkFactory.SetObjectContext(() => new DataShareContext()); }
/// <summary> /// Initializes this instance. /// </summary> /// <remarks></remarks> public static void Initialize() { // Hook up the interception ObjectFactory.Initialize( x => { x.For <IUnitOfWorkFactory>().Use <EFUnitOfWorkFactory>(); x.For(typeof(IRepository <>)).Use(typeof(EFRepository <>)); } ); // We tell the concrete factory what EF model we want to use EFUnitOfWorkFactory.SetObjectContext(() => new BOBCardEntities()); }
public void Test_Holiday_Update_From_File() { string filePath = Path.Combine(Directory.GetCurrentDirectory(), @"Source/Holiday.json"); ISourceGraber <SourceHoliday> sourceGraber = new FileSourceGraber <SourceHoliday>(filePath); IUnitOfWork unitOfWork = EFUnitOfWorkFactory.GetUnitOfWork <HolidayEntities>(); IGenericDataAccess <TWHoliday> dataAccess = new GenericDataAccess <TWHoliday>(unitOfWork); HolidayMaintainer maintanier = new HolidayMaintainer(sourceGraber, dataAccess); var source = maintanier.AddHolidayFromSource(); Assert.AreEqual(true, source); }
public IHttpActionResult CheckDateIsHoliday([FromBody] DateModel value) { DateTime time = value.Time; IUnitOfWork unitOfWork = EFUnitOfWorkFactory.GetUnitOfWork <HolidayEntities>(); IGenericDataAccess <TWHoliday> dataAccess = new GenericDataAccess <TWHoliday>(unitOfWork); HolidayMaintainer maintanier = new HolidayMaintainer(dataAccess); bool result = maintanier.CheckDateIsHoliday(time); var resp = new RespModel() { IsHoliday = result }; return(Json(resp)); }
public void EnumOnPersonTypeRountripsToDatabase() { Person person = CreatePerson(); person.Type = PersonType.Colleague; using (IUnitOfWork unitOfWork = new EFUnitOfWorkFactory().Create()) { PeopleRepository repository = new PeopleRepository(); repository.Add(person); } PeopleRepository repoConfirm = new PeopleRepository(); Person personCheck = repoConfirm.FindById(person.Id); Assert.AreEqual(PersonType.Colleague, personCheck.Type); }
public void CanExecuteQueryAgainstDataContext() { using (var uow = new EFUnitOfWorkFactory().Create()) { var context = DataContextFactory.GetDataContext(); string username = Guid.NewGuid().ToString().Substring(0, 10); var user = new User { UserName = username, Email = "*****@*****.**", PasswordHash = "123456" }; context.Users.Add(user); uow.Commit(false); var personCheck = context.Users.SingleOrDefault(x => x.UserName == username); personCheck.Should().NotBeNull(); context.Users.Remove(user); } }
public void CanGetBasicPerson() { Person person = CreatePerson(); PeopleRepository repository = new PeopleRepository(); using (IUnitOfWork unitOfWork = new EFUnitOfWorkFactory().Create()) { repository.Add(person); } PeopleRepository repositoryConfirm = new PeopleRepository(); Person personConfirm = repositoryConfirm.FindById(person.Id); personConfirm.Id.Should().Be(person.Id); var friendsWithATattoo = repository.FindAll( x => x.FirstName == "Goo" && x.Type == PersonType.Friend); }
public void SetUp() { EFUnitOfWorkFactory.SetObjectContextProvider(() => { var context = new SugiBpmContext(); return(context); }); var builder = new ContainerBuilder(); builder.RegisterType <EFUnitOfWorkFactory>().As <IUnitOfWorkFactory>(); builder.RegisterType <EFRepository <ActionDef> >().As <IRepository <ActionDef> >(); builder.RegisterType <EFRepository <Transition> >().As <IRepository <Transition> >(); builder.RegisterType <EFRepository <ProcessBlock> >().As <IRepository <ProcessBlock> >(); builder.RegisterType <EFRepository <ProcessDefinition> >().As <IRepository <ProcessDefinition> >(); builder.RegisterType <EFRepository <AttributeDef> >().As <IRepository <AttributeDef> >(); builder.RegisterType <EFRepository <Field> >().As <IRepository <Field> >(); builder.RegisterType <EFRepository <User> >().As <IRepository <User> >(); builder.RegisterType <EFRepository <Actor> >().As <IRepository <Actor> >(); builder.RegisterType <EFRepository <Group> >().As <IRepository <Group> >(); builder.RegisterType <EFRepository <Membership> >().As <IRepository <Membership> >(); builder.RegisterType <EFRepository <ProcessInstance> >().As <IRepository <ProcessInstance> >(); builder.RegisterType <EFRepository <Flow> >().As <IRepository <Flow> >(); builder.RegisterType <EFRepository <AttributeInstance> >().As <IRepository <AttributeInstance> >(); builder.RegisterType <DelegationHelper>().As <IDelegationHelper>(); builder.RegisterType <EFRepository <DelegationDef> >().As <IRepository <DelegationDef> >(); builder.RegisterType <OrganizationApplication>().As <IOrganizationApplication>(); builder.RegisterType <ProcessDefinitionApplication>().As <IProcessDefinitionApplication>(); builder.RegisterType <ExecutionApplication>().As <IExecutionApplication>(); var container = builder.Build(); Autofac.Extras.CommonServiceLocator.AutofacServiceLocator serviceLocator = new Autofac.Extras.CommonServiceLocator.AutofacServiceLocator(container); ServiceLocator.SetLocatorProvider(() => serviceLocator); Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console() .CreateLogger(); }
public void SetUp() { EFUnitOfWorkFactory.SetObjectContextProvider(() => { var context = new SugiBpmContext(); return(context); }); var builder = new ContainerBuilder(); builder.RegisterType <EFUnitOfWorkFactory>().As <IUnitOfWorkFactory>(); builder.RegisterType <EFRepository <Actor> >().As <IRepository <Actor> >(); builder.RegisterType <EFRepository <Membership> >().As <IRepository <Membership> >(); var container = builder.Build(); Autofac.Extras.CommonServiceLocator.AutofacServiceLocator serviceLocator = new Autofac.Extras.CommonServiceLocator.AutofacServiceLocator(container); ServiceLocator.SetLocatorProvider(() => serviceLocator); }
private static void InitialiseDatabase() { // Setup StructureMap to determine the concrete repository pattern to use. ObjectFactory.Initialize( x => { x.For <IUnitOfWorkFactory>().Use <EFUnitOfWorkFactory>(); x.For(typeof(IRepository <>)).Use(typeof(Repository <>)); x.For <ISqlTableUtility>().Use <SqlTableUtility>(); x.For <IDataSetSchemaDefinitionService>().Use <DataSetSchemaDefinitionService>(); x.For <IDataSetDetailSqlRepo>().Use <DataSetDetailSqlRepo>(); x.For <ISystemConfigurationService>().Use <SystemConfigurationService>(); x.For <ICacheProvider>().Use <HttpCache>(); x.For <IDataSetDetailCsvProcessor>().Use <DataSetDetailCsvProcessor>(); x.For <IDataSetSchemaService>().Use <DataSetSchemaService>(); } ); // Select an Entity Framework model to use with the factory. EFUnitOfWorkFactory.SetObjectContext(() => new DataShareContext()); //Never recreate the database Database.SetInitializer <DataShareContext>(null); //initialise all services _dataSetSchemaService = new DataSetSchemaService( ObjectFactory.GetInstance <IRepository <DataSetSchema> >() , ObjectFactory.GetInstance <DataSetSchemaDefinitionService>() , ObjectFactory.GetInstance <IRepository <DataSetDetail> >() , ObjectFactory.GetInstance <ISqlTableUtility>()); _uploaderService = new DataSetDetailUploaderService( _dataSetSchemaService , ObjectFactory.GetInstance <IRepository <DataSetDetail> >() , ObjectFactory.GetInstance <IDataSetDetailCsvProcessor>() , ObjectFactory.GetInstance <IDataSetDetailSqlRepo>()); _debugInfoService = new DebugInfoService(ObjectFactory.GetInstance <IRepository <DebugInfo> >()); }
public ClienteRepositoryTests() { var ambientDbContextLocator = new AmbientDbContextLocator(); uowFactory = new EFUnitOfWorkFactory(System.Data.IsolationLevel.ReadCommitted); repository = new ClienteRepository(ambientDbContextLocator); }
public void FixtureSetup() { this.unityContainer = new UnityContainer(); IoC.Initialize( (x, y) => this.unityContainer.RegisterType(x, y), (x, y) => this.unityContainer.RegisterInstance(x, y), (x) => { return unityContainer.Resolve(x); }, (x) => { return unityContainer.ResolveAll(x); }); // Context Factory EFUnitOfWorkFactory ctxFactory = new EFUnitOfWorkFactory(this.ConnectionString(), typeof(DomainContext)); if (!ctxFactory.DatabaseExists()) { ctxFactory.CreateDatabase(); } ctxFactory.ValidateDatabaseSchema(); this.unityContainer.RegisterInstance<IDatabaseManager>(ctxFactory); this.unityContainer.RegisterInstance<IUnitOfWorkFactory>(ctxFactory); this.unityContainer.RegisterType<DbContext, DomainContext>(new InjectionFactory((c) => { return ctxFactory.CurrentDbContext; })); // Repositories this.unityContainer.RegisterType<IEntityARepository, EntityAEFRepository>(new PerResolveLifetimeManager()); this.unityContainer.RegisterType<IEntityBRepository, EntityBEFRepository>(new PerResolveLifetimeManager()); ApplicationContext.User = new CorePrincipal(new CoreIdentity("cmendible", "hexa.auth", "*****@*****.**"), new string[] { }); }