![]() |
VOOZH | about |
dotnet tool install --global EntityFrameworkRuler --version 10.0.7
dotnet new tool-manifestif you are setting up this repo
dotnet tool install --local EntityFrameworkRuler --version 10.0.7
#tool dotnet:?package=EntityFrameworkRuler&version=10.0.7
nuke :add-package EntityFrameworkRuler --version 10.0.7
Automate the customization of the EF Core Reverse Engineered model. Features include:
EF Ruler applies customizations from a rule document stored in the project folder. Rules can be initialized with a call to ef dbcontext scaffold, or they can be fully generated from an EDMX 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."
By default, a rule file generated from EDMX limits tables and columns to just what was in the EDMX. That way, an identical model can be generated.
If it's time to add a table or column to the model, adjust the IncludeUnknownTables or IncludeUnknownColumns flags at the relevant level.
If the database schema contains a lot of tables that you don't want to generate entities for, then enabling IncludeUnknownTables is not a good idea. Instead, manually create the table entry in the rule file (using the Editor) and set IncludeUnknownColumns to true. On the next scaffold, the new entity will be generated fully.
You can remove entities from the model by marking the corresponding table (or column) as Not Mapped.
The ef dbcontext scaffold command does not natively support splitting entity type configurations into separate files. Instead, all type configurations are stored in the same file as the context.
With EF Core 7 and later, EntityFrameworkRuler.Design can split configurations for you.
Just enable "SplitEntityTypeConfigurations" in the rule file (at the root level).
> dotnet tool install --global EntityFrameworkRuler --version <the latest version>
See the NuGet page for details.
> 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>
DB context rules will be extracted from the EDMX and saved in the EF Core project folder.
It is strongly recommended to just run ef dbcontext scaffold with the EntityFrameworkRuler.Design library referenced in order to apply customizations. However, if this is not an option, the following command can apply renaming and type mapping to existing entities (using Roslyn). For very large projects, this can take a minute.
> efruler -a <efCoreProjectBasePath>
While the command line tool, EntityFrameworkRuler.Design package, and VS Extension are intended to provide all the features necessary to customize the reverse engineered model, without writing any code, the API is available and fully extensible if you need to tailor the process further.
Reference NuGet package EntityFrameworkRuler.Common
serviceCollection
.AddRuler()
.AddSingleton<IRuleSerializer, MyBinaryRuleSerializer>()
.AddTransient<IRulerNamingService, MyCustomNamingService>()
.AddTransient<IEdmxParser, MyEdmxParser>()
var generator = new RuleGenerator(); // or use injected IRuleGenerator instance
var response = generator.GenerateRules(edmxPath);
if (response.Success)
await generator.SaveRules(response.Rules.First(), projectBasePath);
var applicator = new RuleApplicator(); // or use injected IRuleApplicator instance
var response = await applicator.ApplyRulesInProjectPath(projectBasePath);
var generator = new RuleGenerator();
var response = generator.GenerateRules(edmxPath);
if (response.Success)
await generator.SaveRules(projectBasePath, dbContextRulesFile: "DbContextRules.json", response.Rules.First());
var applicator = new RuleApplicator();
applicator.Log += (sender, message) => Console.WriteLine(message);
var response = await applicator.ApplyRulesInProjectPath(projectBasePath);
This project is under development! Check back often, and leave comments here.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 is compatible. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.7 | 183 | 2/27/2026 |
| 10.0.7-alpha.0.2 | 76 | 2/27/2026 |
| 10.0.7-alpha.0.1 | 64 | 2/27/2026 |
| 10.0.6 | 119 | 2/27/2026 |
| 10.0.5 | 132 | 2/19/2026 |
| 10.0.4 | 129 | 2/17/2026 |
| 10.0.3 | 143 | 2/17/2026 |
| 10.0.2 | 131 | 2/16/2026 |
| 10.0.2-alpha.0.2 | 89 | 2/16/2026 |
| 10.0.2-alpha.0.1 | 83 | 2/16/2026 |
| 10.0.1 | 138 | 2/16/2026 |
| 10.0.1-alpha.0.1 | 85 | 2/16/2026 |
| 10.0.0 | 123 | 2/16/2026 |
| 9.0.6 | 114 | 2/16/2026 |
| 9.0.5 | 121 | 2/16/2026 |
| 9.0.3-alpha.0.7 | 186 | 11/3/2025 |
| 9.0.3-alpha.0.6 | 182 | 11/3/2025 |
| 9.0.3-alpha.0.5 | 189 | 11/3/2025 |
| 9.0.2 | 304 | 11/29/2024 |
| 9.0.1 | 245 | 11/21/2024 |