コード例 #1
0
        public static IKledexAppBuilder EnsureDomainDbCreated(this IKledexAppBuilder builder)
        {
            using (var serviceScope = builder.App.ApplicationServices.CreateScope())
            {
                var dbContext = serviceScope.ServiceProvider.GetService <DomainDbContext>();
                dbContext.Database.Migrate();
            }

            return(builder);
        }
コード例 #2
0
        public static IKledexAppBuilder EnsureCosmosDbSqlDbCreated(this IKledexAppBuilder builder, IOptions <DomainDbConfiguration> settings)
        {
            var documentClient = builder.App.ApplicationServices.GetService <IDocumentClient>();

            CreateDatabaseIfNotExistsAsync(documentClient, settings.Value.DatabaseId).Wait();
            CreateCollectionIfNotExistsAsync(documentClient, settings.Value.DatabaseId, settings.Value.AggregateCollectionId).Wait();
            CreateCollectionIfNotExistsAsync(documentClient, settings.Value.DatabaseId, settings.Value.CommandCollectionId).Wait();
            CreateCollectionIfNotExistsAsync(documentClient, settings.Value.DatabaseId, settings.Value.EventCollectionId).Wait();

            return(builder);
        }
コード例 #3
0
        public static IKledexAppBuilder EnsureCosmosDbCreated(this IKledexAppBuilder builder)
        {
            var dbContextFactory = builder.App.ApplicationServices.GetService <IDomainDbContextFactory>();

            using (var dbContext = dbContextFactory.CreateDbContext())
            {
                dbContext.Database.EnsureCreated();
            }

            return(builder);
        }