Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when creating Capped and Timeseries collections #228

Open
paolobriones opened this issue Sep 5, 2024 · 1 comment
Open

Error when creating Capped and Timeseries collections #228

paolobriones opened this issue Sep 5, 2024 · 1 comment
Labels
pending investigation up for grabs feature requires community contribution

Comments

@paolobriones
Copy link
Contributor

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)

await DB.InitAsync(
     "somedb", 
     MongoClientSettings.FromConnectionString("...valid_connectionstring...")
);

await DB.CreateCollectionAsync<Book>(o => {
    o.Capped = true;
    o.MaxDocuments = 10000;
});

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

@paolobriones
Copy link
Contributor Author

I also tried this with an existing database... throws an exception
And with an auto-created database via mongodb-entities... still throws an exception

@dj-nitehawk dj-nitehawk added the up for grabs feature requires community contribution label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending investigation up for grabs feature requires community contribution
Projects
None yet
Development

No branches or pull requests

2 participants