title: Can't .net project mongodb connection .Whats wrong
body: <p>My context Class</p>
  <pre><code> public class Context
      {
          private readonly IMongoDatabase _database;
          public Context(IOptions&lt;Settings&gt; settings)
          {
              var client = new MongoClient(settings.Value.ConnectionString);
              _database = client.GetDatabase(settings.Value.Database);
  
          }
          public IMongoCollection&lt;TEntity&gt; GetCollection&lt;TEntity&gt;()
          {
              return _database.GetCollection&lt;TEntity&gt;(typeof(TEntity).Name.Trim());
          }
          public IMongoDatabase GetDatabase()
          {
              return _database;
          }
      }
  </code></pre>
  <p>My AppsettingJson</p>
  <pre><code>&quot;MongoConnection&quot;: {
      &quot;ConnectionString&quot;: &quot;mongodb+srv://username:mypassword@mongodb.net/ODSDataBase?retryWrites=true&amp;w=majority&quot;,
      &quot;Database&quot;: &quot;ODSDataBase&quot;
  </code></pre>
  <p>My Settings class</p>
  <pre><code>public class Settings
      {
          public string ConnectionString;
  
          public string Database;
      }
  </code></pre>
  <p>My Repository injection</p>
  <p>private readonly Context.Context _context;<br />
  private readonly IMongoCollection _collection;</p>
  <pre><code>public MongoRepositoryBase(IOptions&lt;Settings&gt; settings)
          
  {
       _context = new Context.Context(settings);            
       _collection=_context.GetCollection&lt;TEntity&gt;();
  }
  </code></pre>