SpocR 4.1.35
See the version list below for details.
dotnet tool install --global SpocR --version 4.1.35
dotnet new tool-manifest
dotnet tool install --local SpocR --version 4.1.35
#tool dotnet:?package=SpocR&version=4.1.35
nuke :add-package SpocR --version 4.1.35
SpocR

- Scaffolds your Stored Procedures and Models to C# Files
- Easily managed through a CLI interface
- Scalable and extensible architecture
- No rigid dependencies for maximum flexibility
How SpocR works
SpocR extracts your database schema via a provided ConnectionString and stores it in a spocr.json configuration file.
This configuration file is highly customizable, allowing you to select which schemas to include or exclude.
SpocR generates a complete DataContext folder structure with all required C# code for your .NET application (App, API, or Services).
The tool is designed for flexibility. You can:
- Build it as a standalone project (Default mode)
- Use it as a library to integrate into other projects (Library mode)
- Create extensions to enhance existing SpocR libraries (Extension mode)
SpocR supports User-Defined Table Functions and various parameter types. The results of your Stored Procedures will be automatically mapped to strongly-typed models or as List<Model>. It also supports pure JSON-string results from Stored Procedures without building additional model classes.
Generated Folder Structure
./DataContext/
├── Models/[schema]/[StoredProcedureName].cs
├── StoredProcedures/[schema]/[EntityName]Extensions.cs
├── TableTypes/[schema]/[TableTypeName].cs
├── AppDbContext.cs
├── AppDbContextExtensions.cs
├── SqlDataReaderExtensions.cs
└── SqlParameterExtensions.cs
Using the generated SpocR code
Step 1: Register the context
Register IAppDbContext in your application's dependency injection container:
// .NET 6+ in Program.cs
builder.Services.AddAppDbContext();
// Or in Startup.cs for older versions
services.AddAppDbContext();
Step 2: Inject the context
Inject IAppDbContext into your business logic components:
private readonly IAppDbContext _dbContext;
public MyManager(IAppDbContext dbContext)
{
_dbContext = dbContext;
}
Step 3: Call stored procedures
Use the generated extension methods to call your stored procedures:
public Task<List<UserList>> ListAsync(CancellationToken cancellationToken = default)
{
return _dbContext.UserListAsync(User.Id, cancellationToken);
}
Naming Conventions
StoredProcedure Naming Pattern
[EntityName][Action][Suffix]
- EntityName (required): Name of the base SQL table
- Action (required): Create | Update | Delete | (Merge, Upsert) | Find | List
- Suffix (optional): WithChildren | [custom suffix]
Required Result Format for CRUD Operations
For Create, Update, Delete, Merge, and Upsert operations, stored procedures should return:
[ResultId] INT: Operation result status[RecordId] INT: ID of the affected record
Technical Requirements
- Database: SQL Server version 2012 or higher
- Framework: .NET Core / .NET 6+ (supports down to .NET Core 2.1)
- Current Version: 4.0.0 (as of April 2025)
Required .NET Packages
- Microsoft.Data.SqlClient
- Microsoft.Extensions.Configuration
Installation Guide
First, ensure you have the .NET SDK installed (latest version recommended)
Option A: Install from NuGet (Recommended)
dotnet tool install --global SpocR
Option B: Install from GitHub Source
# Clone the repository
git clone https://github.com/nuetzliches/spocr.git
# Uninstall previous versions if needed
dotnet tool uninstall -g spocr
# Build and install from source
cd src
(dotnet msbuild -t:IncrementVersion)
dotnet pack --output ./ --configuration Release
dotnet tool install -g spocr --add-source ./
Using SpocR
Quick Start
To quickly set up your project:
# Create and configure spocr.json
spocr create
# Pull schemas and build DataContext
spocr rebuild
Step-by-Step Approach
If you prefer more control:
# Step 1: Pull database schemas and update spocr.json
spocr pull
# Step 2: Build DataContext folder
spocr build
Removing SpocR
To remove SpocR configuration and/or generated code:
spocr remove
Advanced Configuration
Project Role Types in spocr.json
Project.Role.Kind
- Default: Creates a standalone project with all dependencies
- Lib: Creates a SpocR library for integration into other projects, including AppDbContext and dependencies
- Extension: Creates an extensible project without AppDbContext and dependencies to extend an existing SpocR library. Requires configuring the namespace (Project.Role.LibNamespace) to resolve the SpocR library
Sample Implementation
For a complete example project with stored procedures and API implementation, visit: https://github.com/nuetzliches/nuts
Additional Resources
- Roslyn Quoter - Useful for understanding code generation
- .NET Global Tools - Information about .NET global tools
Known Issues and Limitations
- SQL Server cannot reliably determine the nullable property for computed columns. For cleaner models, wrap computed columns in
ISNULL({computed_expression}, 0)expressions. - When using complex types as parameters, ensure they follow the required table type structure.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.5.0-alpha.12 | 114 | 10/7/2025 |
| 4.1.35 | 205 | 8/4/2025 |
| 4.1.34 | 181 | 8/4/2025 |
| 4.1.33 | 175 | 8/4/2025 |
| 4.1.32 | 140 | 6/6/2025 |
| 4.1.31 | 159 | 6/5/2025 |
| 4.1.30 | 211 | 4/29/2025 |
| 4.1.29 | 210 | 4/29/2025 |
| 4.1.28 | 189 | 4/29/2025 |
| 4.1.27 | 224 | 4/24/2025 |
| 4.1.26 | 210 | 4/24/2025 |
| 4.1.25 | 220 | 4/24/2025 |
| 4.1.24 | 191 | 4/23/2025 |
| 4.1.23 | 198 | 4/23/2025 |
| 4.1.22 | 200 | 4/23/2025 |
| 4.1.21 | 190 | 4/23/2025 |
| 4.1.20 | 200 | 4/23/2025 |
| 4.1.19 | 218 | 4/23/2025 |
| 4.1.18 | 196 | 4/23/2025 |
| 4.1.17 | 198 | 4/23/2025 |
| 4.1.4 | 200 | 4/22/2025 |
| 4.0.1 | 202 | 4/22/2025 |
| 3.2.3 | 180 | 7/10/2024 |
| 3.2.2 | 347 | 11/20/2023 |
| 3.2.1 | 224 | 11/20/2023 |
| 3.1.14 | 336 | 4/18/2023 |
| 3.1.12 | 365 | 2/9/2023 |
| 3.1.11 | 411 | 1/27/2023 |
| 3.1.10 | 376 | 1/27/2023 |
| 3.1.9 | 437 | 11/17/2022 |
| 3.1.7 | 505 | 10/18/2022 |
| 3.1.6 | 516 | 10/4/2022 |
| 3.1.4 | 510 | 9/13/2022 |
| 3.1.3 | 567 | 6/30/2022 |
| 3.1.2 | 562 | 6/30/2022 |
| 3.1.1 | 540 | 6/30/2022 |
| 3.1.0 | 530 | 6/30/2022 |
| 3.0.5 | 566 | 5/17/2022 |
| 3.0.3 | 525 | 5/17/2022 |
| 3.0.2 | 549 | 4/26/2021 |
| 3.0.1 | 539 | 4/26/2021 |
| 3.0.0 | 510 | 4/20/2021 |
| 2.0.4 | 485 | 4/9/2021 |
| 2.0.3 | 560 | 3/12/2021 |
| 2.0.2 | 527 | 3/11/2021 |
| 1.5.20 | 542 | 2/9/2021 |
| 1.5.16 | 580 | 12/3/2020 |
| 1.5.15 | 581 | 12/3/2020 |
| 1.5.14 | 614 | 9/25/2020 |
| 1.5.13 | 644 | 9/22/2020 |
| 1.5.12 | 621 | 9/22/2020 |
| 1.5.11 | 651 | 9/21/2020 |
| 1.5.10 | 676 | 9/20/2020 |
| 1.5.7 | 626 | 9/17/2020 |
| 1.5.4 | 645 | 9/17/2020 |
| 1.5.3 | 640 | 9/16/2020 |
| 1.5.2 | 688 | 9/15/2020 |
| 1.5.1 | 658 | 8/14/2020 |
| 1.5.0 | 716 | 4/17/2020 |
| 1.4.6 | 699 | 3/20/2020 |
| 1.4.5 | 686 | 3/6/2020 |
| 1.4.4 | 653 | 3/2/2020 |
| 1.4.3 | 651 | 2/27/2020 |
| 1.4.2 | 708 | 2/27/2020 |
| 1.4.1 | 686 | 2/7/2020 |
| 1.4.0 | 691 | 2/6/2020 |
| 1.3.7 | 660 | 2/5/2020 |
| 1.3.6 | 669 | 2/3/2020 |
| 1.3.5 | 678 | 1/31/2020 |
| 1.3.4 | 693 | 1/31/2020 |
| 1.3.3 | 705 | 1/30/2020 |
| 1.3.0 | 732 | 1/27/2020 |
| 1.2.3 | 806 | 1/8/2020 |
| 1.2.2 | 700 | 11/21/2019 |
| 1.2.1 | 686 | 11/21/2019 |
| 1.2.0 | 683 | 11/7/2019 |
| 1.1.7.4 | 735 | 10/10/2019 |
| 1.1.7 | 732 | 10/10/2019 |
| 1.1.6 | 743 | 9/24/2019 |
| 1.1.5 | 722 | 9/11/2019 |
| 1.1.4 | 713 | 9/11/2019 |
| 1.1.3 | 700 | 9/5/2019 |
| 1.1.2 | 758 | 8/21/2019 |
| 1.1.1 | 738 | 7/25/2019 |
| 1.0.6 | 729 | 7/22/2019 |
| 1.0.5 | 741 | 7/17/2019 |
| 1.0.4 | 783 | 6/9/2019 |
| 1.0.3 | 771 | 6/7/2019 |
| 1.0.2 | 789 | 6/5/2019 |
| 1.0.1 | 816 | 6/5/2019 |
| 1.0.0 | 748 | 5/29/2019 |
| 0.2.0 | 871 | 4/23/2019 |
| 0.1.3 | 805 | 4/12/2019 |
| 0.1.1 | 833 | 4/11/2019 |