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());
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()))); }