コード例 #1
0
 /// <summary>
 /// Configure the dependency injection services
 /// </summary>
 private static IServiceProvider CreateServices()
 {
     return(new ServiceCollection()
            // Add common FluentMigrator services
            .AddFluentMigratorCore()
            .ConfigureRunner(rb => rb
                             // Add SQLite support to FluentMigrator
                             .AddSqlServer2016()
                             // Set the connection string
                             .WithGlobalConnectionString(ConnectionStringUtils.GetDefaultConnectionString())
                             // Define the assembly containing the migrations
                             .ScanIn(typeof(InitMigration).Assembly).For.Migrations())
            // Enable logging to console in the FluentMigrator way
            .AddLogging(lb => lb.AddFluentMigratorConsole())
            // Build the service provider
            .BuildServiceProvider(false));
 }
コード例 #2
0
        public static ISessionFactory BuildDefaultSession(this Configuration cfg)
        {
            var mapper = new ModelMapper();

            mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());

            HbmMapping mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();

            cfg.AddMapping(mapping);

            cfg.DataBaseIntegration(x =>
            {
                x.ConnectionString = ConnectionStringUtils.GetDefaultConnectionString();

                x.Driver <SqlClientDriver>();
                x.Dialect <MsSql2008Dialect>();
            });

            return(cfg.BuildSessionFactory());
        }