# AddNamespace

- Module: [CommunityToolkit.Aspire.Hosting.SurrealDb](/reference/api/go/communitytoolkit.aspire.hosting.surrealdb.md)
- Version: `13.6.1`
- Kind: `method`
- Defined on: [`SurrealDbServerResource`](/reference/api/go/communitytoolkit.aspire.hosting.surrealdb/surrealdbserverresource.md)
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/tree/d9c2addac6f527ef2e33712d290b84574b455a3b)

Adds a SurrealDB namespace resource to the application model

## Remarks

Add a SurrealDB container to the application model and reference it in a .NET project.
```
var builder = DistributedApplication.CreateBuilder(args);
var db = builder.AddSurrealServer("surreal")
.AddNamespace("ns")
.AddDatabase("db");
var api = builder.AddProject<Projects.Api>("api")
.WithReference(db);
builder.Build().Run();
```

## Definition

```go
func (SurrealDbServerResource) AddNamespace(
    name string,
    options ...*AddNamespaceOptions,
) SurrealDbNamespaceResource
```

## Parameters

- `name` (`string`) -- The name of the resource. This name will be used as the connection string name when referenced in a dependency.
- `options` (`...*AddNamespaceOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*AddNamespaceOptions` argument.

- `NamespaceName` (`*string`) -- The name of the namespace. If not provided, this defaults to the same value as `name`.

## Returns

[`SurrealDbNamespaceResource`](/reference/api/go/communitytoolkit.aspire.hosting.surrealdb/surrealdbnamespaceresource.md) -- A reference to the `IResourceBuilder`.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`SurrealDbServerResource`](/reference/api/go/communitytoolkit.aspire.hosting.surrealdb/surrealdbserverresource.md)
