Example #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());
Example #2
0
        public DemoSqliteContext CreateDbContext(string[] args)
        {
            Console.WriteLine(">>> Design time Sqlite context factory");
            Console.WriteLine(string.Join(", ", args));

            return(new DemoSqliteContext(
                       new StaticConnectionStringProvider <DemoSqliteContext>(
                           SqliteConnectionString.Create().WithDataFile("demo.db")),
                       new TypeDiscoveryProvider <DemoSqliteContext>(
                           new TypeDiscoveryOptions(typeof(ISqliteEntity), "Aska", true),
                           new TypeDiscoveryProvider())));
        }