https://github.com/sedokina/teniry.crudgenerator
Instantly generate CRUD for a .NET application ๐
https://github.com/sedokina/teniry.crudgenerator
api-generator cqrs crud crud-generator dotnet prototyping
Last synced: about 1 month ago
JSON representation
Instantly generate CRUD for a .NET application ๐
- Host: GitHub
- URL: https://github.com/sedokina/teniry.crudgenerator
- Owner: Sedokina
- License: apache-2.0
- Created: 2024-09-03T16:14:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-18T12:43:38.000Z (about 1 year ago)
- Last Synced: 2025-06-23T02:40:29.654Z (12 months ago)
- Topics: api-generator, cqrs, crud, crud-generator, dotnet, prototyping
- Language: C#
- Homepage:
- Size: 605 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
Teniry.CrudGenerator
Instantly generate CRUD for an application
[Report Bug][github-issues-url] ยท [Request Feature][github-issues-url]
[github-issues-url]:https://github.com/Sedokina/Teniry.CrudGenerator/issues
# โจ Features:
- Automatically generate CRUD operations for your domain models
- Generate only the endpoints and handlers you require
- Tailor the generated code to your specific needs with fully customizable configuration
- Use PostgreSQL or MongoDB as your database with Entity Framework Core
- Use minimal APIs for lightweight and efficient endpoint generation
- Provides clear and readable autogenerated code, making it easy to extend and debug
- Based on CQRS pattern (see [Teniry.CQRS](https://github.com/Sedokina/Teniry.CQRS))
- Ideal for both rapid prototyping and large-scale projects with numerous entities.
# ๐ญ Overview
* [Installation](#-installation)
* [Quick start](#-quick-start)
* [Examples](#examples)
* [FAQ](#faq)
* [Who is this library for and would it be a good fit for my project?](#who-is-this-library-for-and-would-it-be-a-good-fit-for-my-project)
* [What is the difference between this library and other libraries that generate CRUD?](#what-is-the-difference-between-this-library-and-other-libraries-that-generate-crud)
* [Is it production ready?](#is-it-production-ready)
* Docs
* [Generator Configuration](docs/entity-generator-configuration.md)
* [DbContext](docs/db-context.md)
* [MongoDb limitations](docs/mongo-limitations.md)
# ๐ฆ Installation
You can install the package via NuGet:
```
Install-Package Teniry.CrudGenerator
```
# ๐จ Quick start
* Create domain model
* Create DBContext
* Create basic generator configuration
* Map autogenerated endpoints
* ๐ Done! You have working CRUD API!
## Create domain model
```csharp
public class Todo {
public Guid Id { get; set; }
public string Description { get; set; }
public bool IsDone { get; set; }
}
```
## Create DBContext
```csharp
using Microsoft.EntityFrameworkCore;
using Teniry.CrudGenerator.Abstractions.DbContext;
[UseDbContext(DbContextDbProvider.Mongo)]
public class TodoDb : DbContext {
public TodoDb(DbContextOptions options) : base(options) { }
public DbSet Todos { get; set; }
}
```
see [DbContext](docs/db-context.md) for more information
## Create basic generator configuration
```csharp
using Teniry.CrudGenerator.Abstractions.Configuration;
public class TodoConfiguration : EntityGeneratorConfiguration { }
```
see [Generator Configuration](docs/entity-generator-configuration.md) for more information on customization
## Map autogenerated endpoints
Add the following code to your `Program.cs` file, to register all necessary services for library to work
```csharp
using AutogeneratedEndpoints;
// your configuration
// ...
// This required because generated code uses CQRS pattern library
builder.Services.AddCqrs();
// This required to provide generated endpoints to the application
app.MapGeneratedEndpoints();
// your other app.Map() calls
// ...
```
> [!NOTE]
> `using AutogeneratedEndpoints;` namespace does not exist if the application is not built yet. It is generated by
> the library
# FAQ
## Who is this library for and would it be a good fit for my project?
This library is for developers who want to quickly generate CRUD for their application.
It would fit you if:
* You need to create a simple CRUD for a small project
* You want to create a prototype quickly
* You have a large project that includes lots of entities that requires CRUD operations and don't include much business
logic
* You want to focus on the business logic, don't want to write a lot of boilerplate code for an application, and stay
flexible in the same time
## What is the difference between this library and other libraries that generate CRUD?
This library is based on the CQRS pattern and generates code that is easy to understand and maintain.
It generates only the necessary endpoints and handlers, which makes the code more readable and maintainable.
It also provides a way to customize the configuration to fit your needs.
## Is it production ready?
Yes! Teniry.CodeGenerator is production ready. But it would be fair to notice that it is quite new library and it may
lack some features that you might need.
# Examples
Check out the [Mongo Todo Web App Example](samples/Teniry.CrudGenerator.Mongo.TodoSampleApi)
and [PostgreSql Todo Web App Example](samples/Teniry.CrudGenerator.PostgreSql.TodoSampleApi)
examples on using Teniry.CrudGenerator library
# Contributing
Feel free to share your ideas through Pull Requests or GitHub Issues. Any contribution or feedback is appreciated!