# MongoDBServerResource Properties

- Package: [Aspire.Hosting.MongoDB](/reference/api/csharp/aspire.hosting.mongodb.md)
- Type: [MongoDBServerResource](/reference/api/csharp/aspire.hosting.mongodb/mongodbserverresource.md)
- Kind: `Properties`
- Members: `9`

A resource that represents a MongoDB container.

## ConnectionStringExpression

- Name: `ConnectionStringExpression`
- Modifiers: `get`
- Returns: `ReferenceExpression`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.MongoDB/MongoDBServerResource.cs#L71)

Gets the connection string for the MongoDB server.

```csharp
public ReferenceExpression ConnectionStringExpression { get; }
```

## Databases

- Name: `Databases`
- Modifiers: `get`
- Returns: `IReadOnlyDictionary<string, string>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.MongoDB/MongoDBServerResource.cs#L130)

A dictionary where the key is the resource name and the value is the database name.

```csharp
public IReadOnlyDictionary<string, string> Databases { get; }
```

## Host

- Name: `Host`
- Modifiers: `get`
- Returns: `EndpointReferenceExpression`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.MongoDB/MongoDBServerResource.cs#L40)

Gets the host endpoint reference for this resource.

```csharp
public EndpointReferenceExpression Host { get; }
```

## PasswordParameter

- Name: `PasswordParameter`
- Modifiers: `nullable` `get`
- Returns: `ParameterResource?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.MongoDB/MongoDBServerResource.cs#L50)

Gets the parameter that contains the MongoDb server password.

```csharp
public ParameterResource? PasswordParameter { get; }
```

## Port

- Name: `Port`
- Modifiers: `get`
- Returns: `EndpointReferenceExpression`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.MongoDB/MongoDBServerResource.cs#L45)

Gets the port endpoint reference for this resource.

```csharp
public EndpointReferenceExpression Port { get; }
```

## PrimaryEndpoint

- Name: `PrimaryEndpoint`
- Modifiers: `get`
- Returns: `EndpointReference`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.MongoDB/MongoDBServerResource.cs#L35)

Gets the primary endpoint for the MongoDB server.

```csharp
public EndpointReference PrimaryEndpoint { get; }
```

## UriExpression

- Name: `UriExpression`
- Modifiers: `get`
- Returns: `ReferenceExpression`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.MongoDB/MongoDBServerResource.cs#L79)

Gets the connection URI expression for the MongoDB server.

```csharp
public ReferenceExpression UriExpression { get; }
```

## Remarks

Format: `mongodb://[user:password@]{host}:{port}[?authSource=admin&authMechanism=SCRAM-SHA-256]`. The credential and query segments are included only when a password is configured.

## UserNameParameter

- Name: `UserNameParameter`
- Modifiers: `nullable` `get`
- Returns: `ParameterResource?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.MongoDB/MongoDBServerResource.cs#L55)

Gets the parameter that contains the MongoDb server username.

```csharp
public ParameterResource? UserNameParameter { get; }
```

## UserNameReference

- Name: `UserNameReference`
- Modifiers: `get`
- Returns: `ReferenceExpression`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.MongoDB/MongoDBServerResource.cs#L64-L66)

Gets a reference to the user name for the MongoDB server.

```csharp
public ReferenceExpression UserNameReference { get; }
```

## Remarks

Returns the user name parameter if specified, otherwise returns the default user name "admin".
