EntityFrameworkRuler.Editor 1.0.17-alpha.0.2

Prefix Reserved
This is a prerelease version of EntityFrameworkRuler.Editor.
There is a newer version of this package available.
See the version list below for details.
dotnet add package EntityFrameworkRuler.Editor --version 1.0.17-alpha.0.2
                    
NuGet\Install-Package EntityFrameworkRuler.Editor -Version 1.0.17-alpha.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EntityFrameworkRuler.Editor" Version="1.0.17-alpha.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EntityFrameworkRuler.Editor" Version="1.0.17-alpha.0.2" />
                    
Directory.Packages.props
<PackageReference Include="EntityFrameworkRuler.Editor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EntityFrameworkRuler.Editor --version 1.0.17-alpha.0.2
                    
#r "nuget: EntityFrameworkRuler.Editor, 1.0.17-alpha.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EntityFrameworkRuler.Editor@1.0.17-alpha.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EntityFrameworkRuler.Editor&version=1.0.17-alpha.0.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=EntityFrameworkRuler.Editor&version=1.0.17-alpha.0.2&prerelease
                    
Install as a Cake Tool

Entity Framework Ruler - Editor

Automate the customization of the EF Core Reverse Engineered model. Supported changes include:

  • Class renaming
  • Property renaming (including both primitives and navigations)
  • Type changing (useful for enum mapping)
  • Skipping non-mapped columns.
  • Forcing inclusion of simple many-to-many entities into the model.

EF Ruler applies customizations from a rule document stored in the project folder. Rules can be fully generated from an EDMX (from old Entity Framework) such that the scaffolding output will align with the old EF6 EDMX-based model.

"EF Ruler provides a smooth upgrade path from EF6 to EF Core by ensuring that the Reverse Engineered model maps perfectly from the old EDMX structure."

Upgrading from EF6 couldn't be simpler:

  1. The the CLI tool to analyze the EDMX for all customizations and generate the rules.
  2. Discard the EDMX (optional of course).
  3. Reference EntityFrameworkRuler.Design from the EF Core project and run the ef dbcontext scaffold command.

Done.

Applying the Model Customizations:

There are two options for applying the rules to a DB context model:

  1. Simply reference EntityFrameworkRuler.Design from the EF Core project. Proceed with CLI scaffolding (as mentioned above). EntityFrameworkRuler.Design is a Design-Time reference package, meaning EF Core can use it during the scaffolding process to customize the generated model, but the assembly will NOT appear in the project build output. It can't get more automated than this.
  2. Use the CLI tool to apply changes to an already generated EF Core model. This approach uses Roslyn to apply code changes. The code analysis is reliable, but for very large models this option can take a minute.

Road Map:

  • EF Power Tools built-in support.
  • Editor library to manage the rules and edit the EF Core model structure with a UI.

This project is under development! Check back often, and leave comments here.

Installation of the CLI tool:

There are 2 ways to use the CLI tool:

  1. Command line:
    > dotnet tool install --global EntityFrameworkRuler 
    
  2. API:
    > dotnet add package EntityFrameworkRuler   
    PM> NuGet\Install-Package EntityFrameworkRuler
    

See the NuGet page for details.

CLI Usage:

To generate rules from an EDMX, run the following:

> efruler -g <edmxFilePath> <efCoreProjectBasePath>

If both paths are the same, i.e. the EDMX is in the EF Core project folder, it is acceptable to run:

> efruler -g <projectFolderWithEdmx>

Structure rules will be extracted from the EDMX and saved in the EF Core project folder.

To Apply rules to an already generated EF Core model:

> efruler -a <efCoreProjectBasePath>

This assumes that you have executed the scaffolding process to generate the model from the database. For details on reverse engineering, go to: https://learn.microsoft.com/en-us/ef/core/managing-schemas/scaffolding/?tabs=dotnet-core-cli

API Usage

To generate rules from an EDMX, use the following class:

EntityFrameworkRuler.Generator.RuleGenerator

To Apply rules to an EF Core model, use the following class:

EntityFrameworkRuler.Applicator.RuleApplicator

Examples

Generate and save rules:
var generator = new RuleGenerator(edmxPath);  
var rules = generator.TryGenerateRules();  
await generator.TrySaveRules(projectBasePath);
Apply rules already in project path:
var applicator = new RuleApplicator(projectBasePath);  
var response = await applicator.ApplyRulesInProjectPath();
More control over which rules are applied:
var applicator = new RuleApplicator(projectBasePath);  
var loadResponse = await applicator.LoadRulesInProjectPath();  
var navRules = loadResponse.Rules.OfType<NavigationNamingRules>().First();
var applyResponse = await applicator.ApplyRules(enumRules);
Customize rule file names:
var generator = new RuleGenerator(edmxPath);  
var rules = generator.TryGenerateRules();  
await generator.TrySaveRules(projectBasePath,  
    new RuleFileNameOptions() {  
        PrimitiveRulesFile = null, // null will skip this file
        NavigationRulesFile = "NavRules.json" 
  }  
);
Handle log activity:
var applicator = new RuleApplicator(projectBasePath);  
applicator.OnLog += (sender, message) => Console.WriteLine(message);
var response = await applicator.ApplyRulesInProjectPath();
Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0-windows7.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
9.0.2 159 11/29/2024
9.0.1 139 11/21/2024
9.0.1-alpha.0.2 72 11/21/2024
1.3.48 151 9/28/2024
1.3.46 171 8/27/2024
1.3.46-alpha.0.1 80 8/27/2024
1.3.45 139 5/2/2024
1.3.44 117 5/2/2024
1.3.43 110 5/2/2024
1.3.42 131 5/2/2024
1.3.40 169 4/4/2024
1.3.9-alpha.0.1 96 4/4/2024
1.3.8 173 3/21/2024
1.3.7 156 3/21/2024
1.3.6 249 12/19/2023
1.3.5 190 11/29/2023
1.3.4 168 11/18/2023
1.2.40 189 10/26/2023
1.2.39 181 10/25/2023
1.2.38 225 10/24/2023
1.2.37 160 10/23/2023
1.2.36 281 7/17/2023
1.2.34-alpha.0.2 135 7/14/2023
1.2.33 235 7/12/2023
1.2.30 259 6/22/2023
1.2.30-alpha.0.1 125 6/21/2023
1.2.29-alpha.0.1 121 6/20/2023
1.2.28 234 6/20/2023
1.2.27 292 4/18/2023
1.2.26 329 3/23/2023
1.2.25 327 3/16/2023
1.2.22 322 3/7/2023
1.2.21 356 3/6/2023
1.2.21-alpha.0.4 147 3/6/2023
1.2.19 356 2/14/2023
1.2.19-alpha.0.4 153 2/14/2023
1.2.17 404 1/31/2023
1.2.16 396 1/27/2023
1.2.15 392 1/27/2023
1.2.14 408 1/26/2023
1.2.13 381 1/25/2023
1.2.10 409 1/25/2023
1.2.9 396 1/25/2023
1.2.8 368 1/25/2023
1.2.7 393 1/24/2023
1.2.6 394 1/24/2023
1.2.5 401 1/24/2023
1.2.4 424 1/18/2023
1.2.3 412 1/17/2023
1.2.3-alpha.0.1 175 1/9/2023
1.2.2 396 1/9/2023
1.2.1-alpha.0.2 174 1/6/2023
1.2.0 402 1/5/2023
1.1.8-alpha.0.16.4 176 1/5/2023
1.1.8-alpha.0.16.2 188 1/5/2023
1.1.8-alpha.0.16.1 188 1/5/2023
1.1.8-alpha.0.16 172 1/5/2023
1.1.8-alpha.0.15 183 1/4/2023
1.1.7 419 12/14/2022
1.1.6-alpha.0.5 166 12/14/2022
1.1.6-alpha.0.4 168 12/13/2022
1.1.6-alpha.0.2 180 12/13/2022
1.1.6-alpha.0.1 164 12/13/2022
1.1.5 392 12/9/2022
1.1.3 432 12/8/2022
1.1.3-alpha.0.2 156 12/8/2022
1.1.3-alpha.0.1 162 12/8/2022
1.1.2 386 12/8/2022
1.1.1 393 12/7/2022
1.1.0 419 12/6/2022
1.0.29-alpha.0.50 166 12/6/2022
1.0.29-alpha.0.48 161 12/6/2022
1.0.29-alpha.0.22 167 11/30/2022
1.0.28 456 11/18/2022
1.0.27 427 11/18/2022
1.0.26 443 11/18/2022
1.0.25 456 11/18/2022
1.0.22 446 11/17/2022
1.0.21 461 11/17/2022
1.0.20 452 11/16/2022
1.0.20-alpha.0.2 163 11/16/2022
1.0.20-alpha.0.1 158 11/16/2022
1.0.19 447 11/16/2022
1.0.18 448 11/16/2022
1.0.17-alpha.0.2 160 11/16/2022
1.0.17-alpha.0.1 167 11/15/2022
1.0.16 475 11/15/2022
1.0.16-alpha.0.2 164 11/15/2022
1.0.14-alpha.0.17 170 11/15/2022
1.0.14-alpha.0.9 162 11/15/2022