Thank you for your great effort.
Is there any generic method to CreateOrUpdateIndex ?
Create if the index (CreateIndexModel) not exists
Update if the index options changed
Do nothing if nothing changed
From googling I found an old workaround that not working with the latest driver version:
As of current version (v2.11), there is no a built-in method as you have described in MongoDB .NET/C# driver. Although there are methods that you should be able to build upon to create the logic.
Having said the above if you’re intending to introduce automatic indexing mechanism, please note that although indexes can improve query performances, indexes may also present some operational considerations. See Operational Considerations for Indexes for more information.
Currently there is no plan to do add a wrapper method.
Please note that index options can not be updated in place. Please consider the impact of dropping and re-creating indexes for a production environment. See also Index Build On Populated Collections.