title: How to Insert document to MongoDB and return the same document or it's ID back using InsertOneAsync in C# .Net
body: <p>I'm writing a generic method to act like data access layer to insert document to MongoDB using C# .Net. My method looks like below. Collection here is a MongoCollection retrieved from MongoDB.</p>
  
  <pre><code>public async T Create(T entity){
  await Collection.InsertOneAsync(entity);
  }
  </code></pre>
  
  <p>I want to return the entity inserted or it's ID which is auto generated by MongoDB back. InsertOneAsync method is returning a task. I tried changing it as below. But its's return type is void. </p>
  
  <pre><code>Collection.InsertOneAsync(entity).GetAwaiter().GetResult();
  </code></pre>
  
  <p>Is there a way to get the id or entity back using InsertOneAsync method. I'm using MongoDB driver for C#.</p>