Skip to content

Commit 2959c89

Browse files
remove ensureCreated (#37)
1 parent 5f21edc commit 2959c89

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

source/includes/code-examples/quick-reference.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// Replace the placeholder with your connection URI
88
var client = new MongoClient("<Your connection URI>");
99
var db = PlanetDbContext.Create(client.GetDatabase("sample_planets"));
10-
db.Database.EnsureCreated();
1110
// end-create-instance
1211

1312
void FindOne()

source/includes/fundamentals/code-examples/configure/ConfigureEFProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
new DbContextOptionsBuilder<MyDbContext>().UseMongoDB(mongoClient, "<Database Name>");
1111

1212
var db = new MyDbContext(dbContextOptions.Options);
13-
db.Database.EnsureCreated();
1413

1514
// Add a new customer and save it to the database
1615
db.Customers.Add(new Customer() { name = "John Doe", Order = "1 Green Tea" });

source/includes/fundamentals/code-examples/configure/UseMongoDB.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
var dbContextOptions =
44
new DbContextOptionsBuilder<MyDbContext>().UseMongoDB(mongoClient, "<Database Name");
55

6-
var db = new MyDbContext(dbContextOptions.Options);
7-
db.Database.EnsureCreated();
6+
var db = new MyDbContext(dbContextOptions.Options);

source/includes/quick-start/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
}
1414
var client = new MongoClient(connectionString);
1515
var db = MflixDbContext.Create(client.GetDatabase("sample_mflix"));
16-
db.Database.EnsureCreated();
1716

1817
var movie = db.Movies.First(m => m.Title == "Back to the Future");
1918
Console.WriteLine(movie.Plot);

source/upgrade.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ Version 8.1.0 Breaking Changes
7272
creating the collection or database
7373
implicitly.
7474

75+
.. note::
76+
77+
Calling the ``EnsureCreated()`` or ``EnsureCreatedAsync()`` method throws
78+
an error if your application is running on a
79+
:atlas:`shared cluster </reference/free-shared-limitations/>`.
80+
Applications running on free and shared clusters should not call these
81+
methods.
82+
7583
If you don't want to ensure :wikipedia:`optimistic concurrency
7684
<Optimistic_concurrency_control>` with transactions, you can
7785
disable automatic transactions by setting ``Database.AutoTransactionBehavior =

0 commit comments

Comments
 (0)