blubberbo
blubberbo

Reputation: 4613

MongoDB C#.NET Connection String Format

I am trying to connect to a MongoDB with my .NET Core 2 controller and I am getting the following error:

MongoDB.Driver.MongoConfigurationException: The connection string 'mongodb://@myapp-a1yri.mongodb.net' is not valid.

I am trying to initialize a MongoClient using the connection string, but I am not sure how to format the connection string and the MongoDB documentation doesn't have anything examples for .NET in it.

This is my current connection string attempt: var client = new MongoClient("mongodb://@myapp-a1yri.mongodb.net");

I am sure it is just simple syntax.

I appreciate the help

Upvotes: 0

Views: 3825

Answers (1)

Sadaqat
Sadaqat

Reputation: 146

I think your @ sign is causing the problem. Please remove the @ sign from connection string and then try.

var client = new MongoClient("mongodb://myapp-a1yri.mongodb.net")

As I am using without @ sign and it is working fine.

Upvotes: 3

Related Questions