SpToolKit generates strongly-typed C# wrappers around SQL Server stored procedures and provides a small runtime to execute them. You maintain a JSON configuration, run a CLI against your database to emit .g.cs files, and inject IStoredProcedureExecutor where generated classes call into the database. The abstractions stay separate from the ADO.NET/EF Core implementation so you can keep generated code stable while swapping execution details.
- .NET 10 (target framework for this repository’s projects)
- SQL Server (metadata and execution are oriented toward T-SQL stored procedures)
NuGet
Published package IDs (see docs/PUBLISHING.md for versioning, CI, and first-time publish):
| Package | Purpose |
|---|---|
SpToolkit.Abstractions |
Contracts and models used by generated code |
SpToolkit.Runtime |
IStoredProcedureExecutor, StoredProcedureExecutor, AddSpToolkit |
SpToolkit.Generator.Cli |
.NET global tool; command: sp-generate |
Current published version (stable): 0.1.0
dotnet add package SpToolkit.Abstractions --version 0.1.0
dotnet add package SpToolkit.Runtime --version 0.1.0
dotnet tool install --global SpToolkit.Generator.Cli --version 0.1.0dotnet add package resolves stable versions automatically. For prerelease versions, add --prerelease or pass the explicit --version string.
Project reference
Add references to the library projects you need, for example:
<ItemGroup>
<ProjectReference Include="..\SpToolKit\src\SpToolkit.Abstractions\SpToolkit.Abstractions.csproj" />
<ProjectReference Include="..\SpToolKit\src\SpToolkit.Runtime\SpToolkit.Runtime.csproj" />
</ItemGroup>Adjust the paths to match where you cloned or vendored the repository. Code generation is SpToolkit.Generator.Cli; run it from source with dotnet run (see Quick Start) or install the SpToolkit.Generator.Cli global tool from NuGet or a local pack.
- CHANGELOG.md — release notes
- docs/PUBLISHING.md — branches, tags, packing, GitHub Actions, NuGet, releases
- Update CHANGELOG (move items from
[Unreleased]into the new version section). - Bump
Versionin Directory.Build.props (or rely on CI-p:Version=…from the tag). - Push
mainand confirm the CI workflow is green. - Create an annotated Git tag that matches the package version, e.g.
v0.1.0orv1.0.0:
git tag -a v0.1.0 -m "v0.1.0" && git push origin v0.1.0 - Open a GitHub Release from that tag; paste the matching CHANGELOG section as the release notes (see docs/PUBLISHING.md).
-
Create or edit the config file
Add asptoolkit.json(or copy from the example below) with at least connection string, output directory, and namespace—or plan to pass those via CLI flags (--connection,--output,--namespace). -
Run the generator CLI
From the repository root (or with paths adjusted), for example:dotnet run --project src/SpToolkit.Generator.Cli/SpToolkit.Generator.Cli.csproj -- --config sptoolkit.json
Use
--dry-runto print the resolved configuration without writing files. When theSpToolkit.Generator.Clitool is installed, the entry point issp-generate. -
Register the executor in DI
In your application startup, callAddSpToolkit(orAddSpToolkit<TDbContext>when reusing an EF Core context). That registersIStoredProcedureExecutorfor use by generated wrapper types.services.AddSpToolkit(opts => { opts.ConnectionString = configuration.GetConnectionString("Default"); });
A commented template with all supported options is in the repository:
Copy it to sptoolkit.json (or another path and pass --config / -c), then fill in values for your environment.
See LICENSE.