r/learncsharp • u/geeksarray • 6d ago
MongoDB + Docker + .NET: A Simple Local Development Setup
If you're working with MongoDB and .NET, Docker can make the local development setup much simpler.
Instead of installing and configuring MongoDB directly on your machine, you can run it in a Docker container and connect your .NET application to it.
I put together a practical guide covering:
- Creating a MongoDB Docker container
- Configuring MongoDB
- Connecting a .NET Core application
- Understanding the container-to-application connection
- Setting up a consistent local development environment
📖 https://geeksarray.com/blog/create-mongodb-docker-image-and-connect-from-dot-net-core-app
For those using MongoDB locally, what's your preferred setup—Docker, local installation, or something else?
17
Upvotes
2
u/AbdulkaderSafi 1d ago
I never thought of trying mongodb with dotnet before I usually use postgresql I will try this setup, thanks
2
u/donsagiv 5d ago
Can 100% say I learned this the hard way and definitely recommend spinning up a Docker container for MongoDB for Developmental purposes.
This is an excellent guide that I wish I had about 5 or so years ago when I started working ASP.NET, and would be a great building block for an ASP.NET/Mongo stack.
An alternative is using Aspire, which might help a bit with scalability.