title: Trying to setup .NET 6 with Cosmos DB EF but issues with setup
body: <p>I'm trying to setup a simple example for using Cosmos DB, .NET 6 using EF.  In the UI project startup,  I am implementing the db factory as such:</p>
  <pre><code>var config = new ConfigurationBuilder()
      .AddJsonFile(&quot;appsettings.json&quot;)
      .Build();
  
  
  // Call CosmosDB connectionString
  var cosmosConnectionString = config[&quot;cosmosService:CosmosConnectionString&quot;];
  var cosmosDatabase = config[&quot;cosmosService:DatabaseName&quot;];
  
      services.AddDbContextFactory&lt;DbContext&gt;(optionsBuilder =&gt;
        optionsBuilder
          .UseCosmos(
            connectionString: cosmosConnectionString,
            databaseName: cosmosDatabase,
            cosmosOptionsAction: options =&gt;
            {
                options.ConnectionMode(Microsoft.Azure.Cosmos.ConnectionMode.Direct);
                options.MaxRequestsPerTcpConnection(20);
                options.MaxTcpConnectionsPerEndpoint(32);
            }));
  </code></pre>
  <p>I am trying to figure out where to put the call for &quot;CreateDatabaseIfNotExistsAsync&quot; but not finding anyway to adding it.  It appears I cannot use the AddDbContextfactory, only implement CosmosClient and add it there.  I would prefer to use context factory but so far not finding anything that work.</p>
  <p>Any suggestions on implementing it that way, that would be great.</p>
  <p>Just an FYI, I have a service project, I've seen examples implementing a provider but again, it uses the CosmosClient as well.</p>
  <p>If there is a way to verify and create database beside this, let me know.</p>
  <p>Any help would be great.</p>
  <p>Thanks!</p>