CHC.EF.Reverse.Poco 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global CHC.EF.Reverse.Poco --version 1.1.0                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local CHC.EF.Reverse.Poco --version 1.1.0                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=CHC.EF.Reverse.Poco&version=1.1.0                
nuke :add-package CHC.EF.Reverse.Poco --version 1.1.0                

EF Core Reverse Engineering Tool

.NET 8.0 code generator for Entity Framework 6.0, creating POCO classes, configurations, and DbContext from existing databases.

Features

Database Schema Support

  • Comprehensive schema reading for SQL Server and MySQL
  • Advanced relationship mapping:
    • One-to-One with unique constraint detection
    • One-to-Many with collection navigation
    • Many-to-Many with junction table support
  • Column property handling:
    • Custom data types and constraints
    • Computed columns and generated values
    • Collation and encoding settings
  • Index and key management:
    • Composite primary/foreign keys
    • Unique and clustered indexes
    • Filtered indexes (SQL Server)

Code Generation

  • Clean POCO entities with relationship navigation
  • Fluent API configurations
  • Documented DbContext
  • XML documentation from schema comments

Configuration Options

  • Multiple config sources (CLI, JSON files)
  • Provider selection (SQL Server/MySQL)
  • Output customization
  • Pluralization options

Installation

dotnet tool install --global CHC.EF.Reverse.Poco

Required packages:

dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.SqlServer # For SQL Server
dotnet add package MySql.EntityFrameworkCore # For MySQL

Usage

Initialize config:

efrev --init

Basic usage:

efrev -c "connection-string" -p "provider-name"

Options

-c, --connection        Connection string
-p, --provider         Provider (SqlServer/MySql)
-n, --namespace        Target namespace
-o, --output           Output directory
--pluralize            Pluralize collection names
--data-annotations     Use data annotations
--config              Custom config path
--settings            Settings file path
--init                Create config files

Configuration

appsettings.json:

{
  "CodeGenerator": {
    "ConnectionString": "Server=localhost;Database=YourDb;",
    "ProviderName": "Microsoft.Data.SqlClient",
    "Namespace": "YourApp.Data",
    "DbContextName": "AppDbContext",
    "UseDataAnnotations": true,
    "IncludeComments": true,
    "IsPluralize": true,
    "OutputDirectory": "./Generated"
  }
}

Output Examples

Entity:

public class Order
{
    public int Id { get; set; }
    public int CustomerId { get; set; }
    
    public virtual Customer Customer { get; set; }
    public virtual ICollection<OrderDetail> Details { get; set; }
}

Configuration:

modelBuilder.Entity<Order>(entity =>
{
    entity.ToTable("Orders");
    entity.HasKey(e => e.Id);
    
    entity.HasOne(e => e.Customer)
          .WithMany(e => e.Orders)
          .HasForeignKey(e => e.CustomerId);
});

License

MIT License

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
3.0.0 127 12/13/2024
2.1.0 100 12/12/2024
2.0.0 116 12/11/2024
1.5.0 95 12/10/2024
1.4.0 106 12/10/2024
1.3.0 102 12/10/2024
1.2.0 106 12/9/2024
1.1.0 105 12/9/2024
1.0.0 114 12/8/2024