예제 #1
0
        private static IHostBuilder CreateConsoleHost(string[] args) =>
        Host.CreateDefaultBuilder(args)
        .ConfigureServices(services =>
        {
            services
            .AddHostedService <StorageDemoService>()
            .AddEntityStorage(opt =>
            {
                opt.UseMariaDb <DemoMariaDbContext>()
                .WithEntitiesAutoDiscovery <IMariaDbEntity>("Aska.Core.EntityStorage.Demo", true)
                .WithConnectionString(
                    MariaDbConnectionString.Create()
                    .WithServer("localhost")
                    .WithDatabase("askaone")
                    .WithUser("askaone")
                    .WithPassword("askaone"));

                opt.UsePostgresql <DemoPsqlContext>()
                .WithEntitiesAutoDiscovery <IPsqlEntity>("Aska.Core.EntityStorage.Demo", true)
                .WithConnectionString(
                    PsqlConnectionString.Create()
                    .WithServer("localhost")
                    .WithDatabase("askaone")
                    .WithUser("askaone")
                    .WithPassword("askaone"));

                opt.UseSqlite <DemoSqliteContext>()
                .WithEntitiesAutoDiscovery <ISqliteEntity>("Aska.Core.EntityStorage.Demo", true)
                .WithConnectionString(SqliteConnectionString.Create()
                                      .WithDataFile("./../../../demo.db"));
            });
        })
        .ConfigureLogging(options =>
                          options.AddConsole());
예제 #2
0
        public DemoPsqlContext CreateDbContext(string[] args)
        {
            Console.WriteLine(">>> Design time Sqlite context factory");
            Console.WriteLine(string.Join(", ", args));

            return(new DemoPsqlContext(
                       new StaticConnectionStringProvider <DemoPsqlContext>(
                           PsqlConnectionString.Create()
                           .WithServer("localhost")
                           .WithDatabase("askaone")
                           .WithUser("askaone")
                           .WithPassword("askaone")),
                       new TypeDiscoveryProvider <DemoPsqlContext>(
                           new TypeDiscoveryOptions(typeof(IPsqlEntity), "Aska", true),
                           new TypeDiscoveryProvider())));
        }