Você pode substituir um documento por outro utilizando o método síncrono ReplaceOne() ou o método assíncrono ReplaceOneAsync() em um objeto de collection.
Exemplo
O código a seguir substitui o primeiro documento na collection restaurants que tem um valor de "Pizza" no campo cuisine. Após a substituição, este documento terá um campo name com um valor de "Mongo's Pizza" e novos valores para os campos address e borough.
Selecione a aba Asynchronous ou Synchronous para ver o código correspondente.
// Creates a filter for all restaurant documents that have a "cuisine" value of "Pizza" var filter = Builders<Restaurant>.Filter     .Eq(r => r.Cuisine, "Pizza"); // Finds the ID of the first restaurant document that matches the filter var oldPizzaRestaurant = _restaurantsCollection.Find(filter).First(); var oldId = oldPizzaRestaurant.Id; // Generates a new restaurant document Restaurant newPizzaRestaurant = new() {        Id = oldId,     Name = "Mongo's Pizza",     Cuisine = "Pizza",     Address = new Address()     {         Street = "Pizza St",         ZipCode = "10003"     },     Borough = "Manhattan", }; // Asynchronously replaces the existing restaurant document with the new document return await _restaurantsCollection.ReplaceOneAsync(filter, newPizzaRestaurant); 
Para obter um exemplo totalmente executável da operação ReplaceOneAsync(), consulte a amostra de código ReplaceOneAsync.
// Creates a filter for all restaurant documents that have a "cuisine" value of "Pizza" var filter = Builders<Restaurant>.Filter     .Eq(r => r.Cuisine, "Pizza"); // Finds the ID of the first restaurant document that matches the filter var oldPizzaRestaurant = _restaurantsCollection.Find(filter).First(); var oldId = oldPizzaRestaurant.Id; // Generates a new restaurant document Restaurant newPizzaRestaurant = new() {     Id = oldId,     Name = "Mongo's Pizza",     Cuisine = "Pizza",     Address = new Address()     {         Street = "Pizza St",         ZipCode = "10003"     },     Borough = "Manhattan", }; // Replaces the existing restaurant document with the new document return _restaurantsCollection.ReplaceOne(filter, newPizzaRestaurant); 
Para obter um exemplo totalmente executável da operação ReplaceOne(), consulte a amostra de código ReplaceOne.
Resultado esperado
A execução de qualquer um dos exemplos completos anteriores imprime os seguintes resultados:
First pizza restaurant before replacement: J&V Famous Pizza Restaurants modified by replacement: 1 First pizza restaurant after replacement: Mongo's Pizza Resetting sample data...done. 
Informações adicionais
Para saber mais sobre a substituição de documentos, consulte o guia Substituir documentos.
Para saber mais sobre como usar construtores, consulte Operações com construtores.