{"id":37032156,"url":"https://github.com/nuetzliches/spocr","last_synced_at":"2026-01-14T03:57:06.036Z","repository":{"id":41294072,"uuid":"144118295","full_name":"nuetzliches/spocr","owner":"nuetzliches","description":"Model generation from stored procedures made easy","archived":false,"fork":false,"pushed_at":"2025-11-26T23:10:19.000Z","size":9553,"stargazers_count":13,"open_issues_count":6,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-29T17:58:28.106Z","etag":null,"topics":["dotnet-core","generator","sql","storedprocedure"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nuetzliches.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-08-09T07:45:29.000Z","updated_at":"2025-11-26T23:09:13.000Z","dependencies_parsed_at":"2025-04-22T16:37:41.570Z","dependency_job_id":"9f91d333-e008-47bd-b39d-62b3d817c9a8","html_url":"https://github.com/nuetzliches/spocr","commit_stats":null,"previous_names":[],"tags_count":101,"template":false,"template_full_name":null,"purl":"pkg:github/nuetzliches/spocr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuetzliches%2Fspocr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuetzliches%2Fspocr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuetzliches%2Fspocr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuetzliches%2Fspocr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuetzliches","download_url":"https://codeload.github.com/nuetzliches/spocr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuetzliches%2Fspocr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet-core","generator","sql","storedprocedure"],"created_at":"2026-01-14T03:57:05.449Z","updated_at":"2026-01-14T03:57:06.027Z","avatar_url":"https://github.com/nuetzliches.png","language":"C#","readme":"\u003e **Deprecation notice:** SpocR is no longer maintained. Please migrate to [Xtraq](https://github.com/nuetzliches/xtraq) using the guide at https://nuetzliches.github.io/xtraq/getting-started/migrating-from-spocr. The CLI now emits a warning for every invocation and future updates will only happen in Xtraq.\n\n# SpocR [![Publish NuGet](https://github.com/nuetzliches/spocr/actions/workflows/dotnet.yml/badge.svg)](https://github.com/nuetzliches/spocr/actions/workflows/dotnet.yml) [![NuGet Badge](https://img.shields.io/nuget/v/SpocR.svg)](https://www.nuget.org/packages/SpocR/)\n\n- Scaffolds your Stored Procedures and Models to C# Files\n- Easily managed through a CLI interface\n- Scalable and extensible architecture\n- No rigid dependencies for maximum flexibility\n\n# How SpocR works\n\nSpocR extracts your database schema via a provided ConnectionString and stores it in a `spocr.json` configuration file.\nThis configuration file is highly customizable, allowing you to select which schemas to include or exclude.\n\nSpocR generates a complete DataContext folder structure with all required C# code for your .NET application (App, API, or Services).\n\nThe tool is designed for flexibility. You can:\n\n- Build it as a standalone project (Default mode)\n- Use it as a library to integrate into other projects (Library mode)\n- Create extensions to enhance existing SpocR libraries (Extension mode)\n\nSpocR 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\u003cModel\u003e. It also supports pure JSON-string results from Stored Procedures without building additional model classes.\n\n## Generated Folder Structure\n\n```\n./DataContext/\n  ├── Models/[schema]/[StoredProcedureName].cs\n  ├── StoredProcedures/[schema]/[EntityName]Extensions.cs\n  ├── TableTypes/[schema]/[TableTypeName].cs\n  ├── AppDbContext.cs\n  ├── AppDbContextExtensions.cs\n  ├── SqlDataReaderExtensions.cs\n  └── SqlParameterExtensions.cs\n```\n\n## Using the generated SpocR code\n\n### Step 1: Register the context\n\nRegister `IAppDbContext` in your application's dependency injection container:\n\n```csharp\n// .NET 6+ in Program.cs\nbuilder.Services.AddAppDbContext();\n\n// Or in Startup.cs for older versions\nservices.AddAppDbContext();\n```\n\n### Step 2: Inject the context\n\nInject `IAppDbContext` into your business logic components:\n\n```csharp\nprivate readonly IAppDbContext _dbContext;\n\npublic MyManager(IAppDbContext dbContext)\n{\n    _dbContext = dbContext;\n}\n```\n\n### Step 3: Call stored procedures\n\nUse the generated extension methods to call your stored procedures:\n\n```csharp\npublic Task\u003cList\u003cUserList\u003e\u003e ListAsync(CancellationToken cancellationToken = default)\n{\n    return _dbContext.UserListAsync(User.Id, cancellationToken);\n}\n```\n\n# Naming Conventions\n\n## StoredProcedure Naming Pattern\n\n#### `[EntityName][Action][Suffix]`\n\n- **EntityName** (required): Name of the base SQL table\n- **Action** (required): Create | Update | Delete | (Merge, Upsert) | Find | List\n- **Suffix** (optional): WithChildren | [custom suffix]\n\n## Required Result Format for CRUD Operations\n\nFor Create, Update, Delete, Merge, and Upsert operations, stored procedures should return:\n\n- `[ResultId] INT`: Operation result status\n- `[RecordId] INT`: ID of the affected record\n\n# Technical Requirements\n\n- **Database**: SQL Server version 2012 or higher\n- **Framework**: .NET Core / .NET 6+ (supports down to .NET Core 2.1)\n- **Current Version**: 4.0.0 (as of April 2025)\n\n## Required .NET Packages\n\n- Microsoft.Data.SqlClient\n- Microsoft.Extensions.Configuration\n\n# Installation Guide\n\nFirst, ensure you have the [.NET SDK](https://dotnet.microsoft.com/download) installed (latest version recommended)\n\n## Option A: Install from NuGet (Recommended)\n\n```\ndotnet tool install --global SpocR\n```\n\n## Option B: Install from GitHub Source\n\n```\n# Clone the repository\ngit clone https://github.com/nuetzliches/spocr.git\n\n# Uninstall previous versions if needed\ndotnet tool uninstall -g spocr\n\n# Build and install from source\ncd src\n(dotnet msbuild -t:IncrementVersion)\ndotnet pack --output ./ --configuration Release\ndotnet tool install -g spocr --add-source ./\n```\n\n# Using SpocR\n\n## Quick Start\n\nTo quickly set up your project:\n\n```\n# Create and configure spocr.json\nspocr create\n\n# Pull schemas and build DataContext\nspocr rebuild\n```\n\n## Step-by-Step Approach\n\nIf you prefer more control:\n\n```\n# Step 1: Pull database schemas and update spocr.json\nspocr pull\n\n# Step 2: Build DataContext folder\nspocr build\n```\n\n## Removing SpocR\n\nTo remove SpocR configuration and/or generated code:\n\n```\nspocr remove\n```\n\n# Advanced Configuration\n\n## Project Role Types in spocr.json\n\n### Project.Role.Kind\n\n- **Default**: Creates a standalone project with all dependencies\n- **Lib**: Creates a SpocR library for integration into other projects, including AppDbContext and dependencies\n- **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\n\n# Sample Implementation\n\nFor a complete example project with stored procedures and API implementation, visit:\nhttps://github.com/nuetzliches/nuts\n\n# Additional Resources\n\n- [Roslyn Quoter](http://roslynquoter.azurewebsites.net/) - Useful for understanding code generation\n- [.NET Global Tools](https://natemcmaster.com/blog/2018/05/12/dotnet-global-tools/) - Information about .NET global tools\n\n# Known Issues and Limitations\n\n- SQL Server cannot reliably determine the nullable property for computed columns. For cleaner models, wrap computed columns in `ISNULL({computed_expression}, 0)` expressions.\n- When using complex types as parameters, ensure they follow the required table type structure.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuetzliches%2Fspocr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuetzliches%2Fspocr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuetzliches%2Fspocr/lists"}