dj-nitehawk / MongoDB.Entities

A data access library for MongoDB with an elegant api, LINQ support and built-in entity relationship management
https://mongodb-entities.com
MIT License
543 stars 69 forks source link

Index creation problem with version 23.1.1 in .net 8 #227

Closed huseyingoztok closed 1 month ago

huseyingoztok commented 1 month ago

Hello,

I'm having trouble creating indexes in .NET Core 8. I’m providing a sample code below. What could be the reason why the indexes are not being created?

await DB.Index() .Key(x => x.A, KeyType.Text) .Key(x => x.B, KeyType.Text) .Key(x => x.C, KeyType.Text) .CreateAsync();

Best regards.

paolobriones commented 1 month ago

You must specify the target Entity class in your call ie: await DB.Index< ClassThatImplementsIEntity >() .Key(x => x.A, KeyType.Text) .Key(x => x.B, KeyType.Text) .Key(x => x.C, KeyType.Text) .CreateAsync();

huseyingoztok commented 1 month ago

Actually, I'm trying it the way you suggested, but the indexes are not being created. @paolobriones @dj-nitehawk

await DB.Index<Item>() .Key(x => x.Make, KeyType.Text) .Key(x => x.Model, KeyType.Text) .Key(x => x.Color, KeyType.Text) .CreateAsync();

dj-nitehawk commented 1 month ago

@huseyingoztok can you attach a small repro project pls? index creation works fine last i checked.