コード例 #1
0
        private static FrameworkConfigurator RegisterMigrationAction(this FrameworkConfigurator configurator)
        {
            return(configurator.RegisterInitializationAction(async resolver =>
            {
                var factory = resolver.Resolve <IFrameworkContextFactory>();

                using (var context = await factory.CreateContext())
                {
                    context.Migrate();
                }
            }));
        }
コード例 #2
0
        public static FrameworkConfigurator UseScopedContext <TContextInterface>(
            this FrameworkConfigurator configurator,
            Func <DbContextOptions, TContextInterface> factoryMethod)
            where TContextInterface : IScopedContex
        {
            configurator.RegisterSingelton <
                ISessionScopedContextFactory <TContextInterface>,
                SessionScopedContextFactory <TContextInterface> >();

            configurator.RegisterInitializationAction(async resolver =>
            {
                var factory = resolver.Resolve <ISessionScopedContextFactory <TContextInterface> >();
                factory.Initialize(factoryMethod);
            });

            return(configurator);
        }