DBAdminPanel.SourceGenerator
0.0.3-alpha
dotnet add package DBAdminPanel.SourceGenerator --version 0.0.3-alpha
NuGet\Install-Package DBAdminPanel.SourceGenerator -Version 0.0.3-alpha
<PackageReference Include="DBAdminPanel.SourceGenerator" Version="0.0.3-alpha" />
<PackageVersion Include="DBAdminPanel.SourceGenerator" Version="0.0.3-alpha" />
<PackageReference Include="DBAdminPanel.SourceGenerator" />
paket add DBAdminPanel.SourceGenerator --version 0.0.3-alpha
#r "nuget: DBAdminPanel.SourceGenerator, 0.0.3-alpha"
#:package DBAdminPanel.SourceGenerator@0.0.3-alpha
#addin nuget:?package=DBAdminPanel.SourceGenerator&version=0.0.3-alpha&prerelease
#tool nuget:?package=DBAdminPanel.SourceGenerator&version=0.0.3-alpha&prerelease
DBAdminPanel.SourceGenerator
<div align="center"> <img src="logo.svg" alt="DBAdminPanel SourceGenerator Logo" width="128" height="128">
Source generator for DBAdminPanel that automatically generates controllers, endpoints, and metadata classes from Entity Framework Core models.
</div>
📦 About This Package
This is the source generator component of DBAdminPanel. It automatically generates code at compile time to create:
- MVC Controllers with full CRUD operations
- REST API Endpoints for programmatic access
- Metadata Classes for entity information
- Dashboard Endpoints for the admin panel UI
- Entity Relationship Diagrams using Mermaid
⚠️ Important Note
You typically don't need to install this package directly!
The DBAdminPanel package automatically includes this source generator as a dependency. Only install this package separately if you need to:
- Use the source generator without the UI components
- Customize the source generation behavior
- Develop extensions for DBAdminPanel
📦 Installation
If you need to install this package separately:
dotnet add package DBAdminPanel.SourceGenerator
Or via Package Manager Console:
Install-Package DBAdminPanel.SourceGenerator
🎯 How It Works
The source generator:
- Scans your project for
DbContextclasses - Identifies all
DbSet<T>properties - Analyzes entity properties, relationships, and keys
- Generates code at compile time (zero runtime overhead)
- Places all generated code in the
DBAdminPanel.Generatednamespace
🔍 Generated Code
Controllers
For each entity in your DbContext, the generator creates:
namespace DBAdminPanel.Generated.Controllers
{
public partial class {EntityName}Controller : Controller
{
// Full CRUD operations
// Index, Create, Edit, Details, Delete actions
}
}
API Endpoints
REST API endpoints are generated using minimal APIs:
namespace DBAdminPanel.Generated.Endpoints
{
public static class EntityEndpoints
{
public static void MapAllEntityEndpoints(WebApplication app)
{
// GET, POST, PUT, DELETE endpoints for all entities
}
}
}
Metadata Classes
Entity metadata is generated for UI generation:
namespace DBAdminPanel.Generated.Metadata
{
public class {EntityName}Metadata
{
// Property information
// Validation rules
// Relationships
// Display names
}
}
📋 Requirements
- .NET Standard 2.0 compatible (works with .NET 8.0, 9.0, 10.0+)
- Microsoft.CodeAnalysis.CSharp 4.12.0+
- Entity Framework Core (in the consuming project)
🔧 Configuration
The source generator works automatically - no configuration needed! It will:
- Detect all
DbContextclasses in your project - Find all
DbSet<T>properties - Generate controllers and endpoints automatically
- Work with any EF Core provider (SQL Server, PostgreSQL, SQLite, etc.)
🎨 Customization
To customize the generated code, you can:
- Extend Generated Controllers: Use partial classes to add custom logic
- Override Endpoints: Map your own endpoints after calling
UseDBAdminPanel() - Custom Metadata: Extend metadata classes for additional information
📝 Example
When you have a DbContext like this:
public class BlogDbContext : DbContext
{
public BlogDbContext(DbContextOptions<BlogDbContext> options) : base(options) { }
public DbSet<BlogPost> BlogPosts { get; set; }
public DbSet<Category> Categories { get; set; }
}
The source generator automatically creates:
BlogPostControllerwith CRUD actionsCategoryControllerwith CRUD actions- API endpoints for both entities
- Metadata classes for both entities
- Dashboard endpoints listing all entities
🔍 Viewing Generated Code
To see the generated code:
- Build your project
- Navigate to:
obj/Debug/netX.X/generated/ - Look for files in the
DBAdminPanel.Generatednamespace
Or use Visual Studio's "Show All Files" to view generated files.
🐛 Troubleshooting
Generated code not appearing
- Ensure your project references this package
- Rebuild your solution (Clean + Build)
- Check that your
DbContextclasses are public and accessible - Verify
DbSet<T>properties are public
IntelliSense not working
- Restart your IDE
- Rebuild the solution
- Clear the
objandbinfolders and rebuild
Compilation errors
- Check that your entity classes are properly defined
- Ensure primary keys are correctly identified
- Verify Entity Framework Core is properly configured
📚 Related Packages
- DBAdminPanel - Main package (includes this source generator)
- Entity Framework Core - Required in your project
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
💬 Support
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Join our discussions
🙏 Acknowledgments
- Built with .NET Source Generators
- Uses Microsoft.CodeAnalysis.CSharp
<div align="center"> Made with ❤️ by the DBAdminPanel team
⭐ Star us on GitHub | 📦 NuGet Package </div>
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.3-alpha | 88 | 1/8/2026 |
| 0.0.2-alpha | 81 | 1/8/2026 |
| 0.0.1-alpha | 78 | 1/8/2026 |