# Description of Changes <!-- Please describe your change, mention any related tickets, and so on here. --> - Bumps version to 2.2.0 # API and ABI breaking changes <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> None # Expected complexity level and risk - 1 - this is just a version bump <!-- How complicated do you think these changes are? Grade on a scale from 1 to 5, where 1 is a trivial change, and 5 is a deep-reaching and complex change. This complexity rating applies not only to the complexity apparent in the diff, but also to its interactions with existing and future code. If you answered more than a 2, explain what is complex about the PR, and what other components it interacts with in potentially concerning ways. --> # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [x] Version number is correct (`2.2.0`) - [x] BSL license file has been updated with the new date and version number --------- Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com> Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Get a SpacetimeDB C# app running in under 5 minutes.
Prerequisites
- .NET 8 SDK installed
- SpacetimeDB CLI installed
Install the SpacetimeDB CLI before continuing.
Install .NET WASI workload
SpacetimeDB C# modules compile to WebAssembly using the WASI experimental workload.
dotnet workload install wasi-experimental
Create your project
Run the spacetime dev command to create a new project with a C# SpacetimeDB module.
This will start the local SpacetimeDB server, compile and publish your module, and generate C# client bindings.
spacetime dev --template basic-cs
Explore the project structure
Your project contains both server and client code.
Edit spacetimedb/Lib.cs to add tables and reducers. Use the generated bindings in the client project.
my-spacetime-app/
├── spacetimedb/ # Your SpacetimeDB module
│ ├── StdbModule.csproj
│ └── Lib.cs # Server-side logic
├── client.csproj
├── Program.cs # Client application
└── module_bindings/ # Auto-generated types
Understand tables and reducers
Open spacetimedb/Lib.cs to see the module code. The template includes a Person table and two reducers: Add to insert a person, and SayHello to greet everyone.
Tables store your data. Reducers are functions that modify data — they're the only way to write to the database.
using SpacetimeDB;
public static partial class Module
{
[SpacetimeDB.Table(Accessor = "Person", Public = true)]
public partial struct Person
{
public string Name;
}
[SpacetimeDB.Reducer]
public static void Add(ReducerContext ctx, string name)
{
ctx.Db.Person.Insert(new Person { Name = name });
}
[SpacetimeDB.Reducer]
public static void SayHello(ReducerContext ctx)
{
foreach (var person in ctx.Db.Person.Iter())
{
Log.Info($"Hello, {person.Name}!");
}
Log.Info("Hello, World!");
}
}
Test with the CLI
Open a new terminal and navigate to your project directory. Then use the SpacetimeDB CLI to call reducers and query your data directly.
cd my-spacetime-app
# Call the add reducer to insert a person
spacetime call add Alice
# Query the person table
spacetime sql "SELECT * FROM Person"
name
---------
"Alice"
# Call say_hello to greet everyone
spacetime call say_hello
# View the module logs
spacetime logs
2025-01-13T12:00:00.000000Z INFO: Hello, Alice!
2025-01-13T12:00:00.000000Z INFO: Hello, World!
Next steps
- See the Chat App Tutorial for a complete example
- Read the C# SDK Reference for detailed API docs