I have a .net core project with MongoDB.
Before starting to work with this I need to create DB for this manually.
I mean I need to go mongo shell and use next commands like this:
use admin
db.createUser(
{
user: "admin",
pwd: "abc123!",
roles: [ { role: "root", db: "admin" } ]
}
);
exit;
But I don't like do this every time when I need to deploy my project.
How can I automate this process and creating DB dynamically from C# code or use some other solution if it's possible?
P.S. I use this article for building work with MongoDB + .net core.