This will throw an exception on DB.CreateCollectionAsync():
System.TypeInitializationException: The type initializer for 'MongoDB.Entities.Cache`1' threw an exception.
---> System.InvalidOperationException: Database connection is not initialized for [Default]
at IMongoDatabase MongoDB.Entities.DB.Database(string name)
at IMongoDatabase MongoDB.Entities.TypeMap.GetDatabase(Type entityType)
at void MongoDB.Entities.Cache<T>.Initialize()
at static MongoDB.Entities.Cache<T>()
--- End of inner exception stack trace ---
at IMongoDatabase MongoDB.Entities.Cache<T>.get_Database()
at IMongoDatabase MongoDB.Entities.DB.Database<T>()
I tried putting DB.DatabaseFor<Book>("somedb"); before the call to
DB.CreateCollectionAsync()... same exception
I am also encountering this now on v23.1.1 using MongoDB v7.0.14 I was trying to create a capped collection (as per documentation)
This will throw an exception on DB.CreateCollectionAsync():
I tried putting
DB.DatabaseFor<Book>("somedb");
before the call toDB.CreateCollectionAsync()
... same exception