File tree Expand file tree Collapse file tree 5 files changed +9
-5
lines changed
fundamentals/code-examples/configure Expand file tree Collapse file tree 5 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 77// Replace the placeholder with your connection URI
88var client = new MongoClient ( "<Your connection URI>" ) ;
99var db = PlanetDbContext . Create ( client . GetDatabase ( "sample_planets" ) ) ;
10- db . Database . EnsureCreated ( ) ;
1110// end-create-instance
1211
1312void FindOne ( )
Original file line number Diff line number Diff line change 1010 new DbContextOptionsBuilder < MyDbContext > ( ) . UseMongoDB ( mongoClient , "<Database Name>" ) ;
1111
1212var db = new MyDbContext ( dbContextOptions . Options ) ;
13- db . Database . EnsureCreated ( ) ;
1413
1514// Add a new customer and save it to the database
1615db . Customers . Add ( new Customer ( ) { name = "John Doe" , Order = "1 Green Tea" } ) ;
Original file line number Diff line number Diff line change 33var 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 ) ;
Original file line number Diff line number Diff line change 1313}
1414var client = new MongoClient ( connectionString ) ;
1515var db = MflixDbContext . Create ( client . GetDatabase ( "sample_mflix" ) ) ;
16- db . Database . EnsureCreated ( ) ;
1716
1817var movie = db . Movies . First ( m => m . Title == "Back to the Future" ) ;
1918Console . WriteLine ( movie . Plot ) ;
Original file line number Diff line number Diff 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 =
You can’t perform that action at this time.
0 commit comments