/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public virtual async Task <bool> EnsureCreatedAsync(CancellationToken cancellationToken = default) { var created = await _cosmosClient.CreateDatabaseIfNotExistsAsync(cancellationToken) .ConfigureAwait(false); foreach (var entityType in _model.GetEntityTypes()) { var containerName = entityType.GetContainer(); if (containerName != null) { created |= await _cosmosClient.CreateContainerIfNotExistsAsync( containerName, GetPartitionKeyStoreName(entityType), cancellationToken) .ConfigureAwait(false); } } if (created) { await SeedAsync(cancellationToken).ConfigureAwait(false); } return(created); }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public virtual async Task <bool> EnsureCreatedAsync(CancellationToken cancellationToken = default) { var model = _designTimeModel.Model; var created = await _cosmosClient.CreateDatabaseIfNotExistsAsync(model.GetThroughput(), cancellationToken) .ConfigureAwait(false); foreach (var container in GetContainersToCreate(model)) { created |= await _cosmosClient.CreateContainerIfNotExistsAsync(container, cancellationToken) .ConfigureAwait(false); } if (created) { await SeedAsync(cancellationToken).ConfigureAwait(false); } return(created); }