EntityFrameworkRuler.Common
1.2.36
Prefix Reserved
See the version list below for details.
dotnet add package EntityFrameworkRuler.Common --version 1.2.36
NuGet\Install-Package EntityFrameworkRuler.Common -Version 1.2.36
<PackageReference Include="EntityFrameworkRuler.Common" Version="1.2.36" />
paket add EntityFrameworkRuler.Common --version 1.2.36
#r "nuget: EntityFrameworkRuler.Common, 1.2.36"
// Install EntityFrameworkRuler.Common as a Cake Addin #addin nuget:?package=EntityFrameworkRuler.Common&version=1.2.36 // Install EntityFrameworkRuler.Common as a Cake Tool #tool nuget:?package=EntityFrameworkRuler.Common&version=1.2.36
Entity Framework Ruler - Common
This library supports the tooling in Entity Framework Ruler and can be referenced directly from your project if you want to drive EF Ruler programmatically.
Automate the customization of the EF Core Reverse Engineered model. Features include:
- Legacy EF6 (EDMX) migration support
- Class renaming
- Property renaming (including both primitives and navigations)
- Type changing (useful for enum mapping)
- Custom navigations that have no database foreign key, such as adding navigations to views
- Table splitting (multiple entities using subsets of columns from the same table)
- Entity inheritance (TPH, TPT, TPC)
- Auto-naming tables and columns using regex
- Skipping tables or columns
- Forcing inclusion of simple many-to-many entities into the model
- Entity type configuration file splitting
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."
Upgrading from EF6 with EDMX:
- Use the command line tool or the VS Extension to generated DB Context rules from an EDMX file.
- Reference EntityFrameworkRuler.Design from the EF Core project.
- Run the ef dbcontext scaffold command and the design-time service will do the rest.
Initializing DB Context Rules without an EDMX:
- Reference EntityFrameworkRuler.Design from the EF Core project.
- Run the ef dbcontext scaffold command and a complete rule file will be generated based on the reverse engineered model. The rules can then be modified, and changes applied by re-running the scaffold command.
DB Context Customization and Ongoing DB Maintenance
- Edit the rules json by hand, or with the VS Extension installed, right click on the rules file and go to Edit DB Context Rules.
- Apply the customizations (see below).
Applying Model Customizations:
- Reference NuGet package EntityFrameworkRuler.Design from the EF Core project. This is a design-time reference, meaning it will not appear in the project build output, but will interact with EF Core's reverse engineer process.
- Run the ef dbcontext scaffold command and the design-time service will apply all changes as per the json rule file. The rule file itself will also sync up with the reverse engineered model.
Adding or Removing Tables From the Model:
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.
Entity Configuration Splitting:
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 EF7, EntityFrameworkRuler.Design can split configurations for you.
Just enable "SplitEntityTypeConfigurations" in the rule file (at the root level).
Installation of the Command Line Tool:
> dotnet tool install --global EntityFrameworkRuler --version <the latest version>
See the NuGet page for details.
Command Line Tool 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>
DB context 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:
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>
API Usage
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
To override default services:
serviceCollection
.AddRuler()
.AddSingleton<IRuleSerializer, MyBinaryRuleSerializer>()
.AddTransient<IRulerNamingService, MyCustomNamingService>()
.AddTransient<IEdmxParser, MyEdmxParser>()
To generate rules from an EDMX:
var generator = new RuleGenerator(); // or use injected IRuleGenerator instance
var response = generator.GenerateRules(edmxPath);
if (response.Success)
await generator.SaveRules(response.Rules.First(), projectBasePath);
Apply rules using Roslyn to a project with rules file in the same path:
var applicator = new RuleApplicator(); // or use injected IRuleApplicator instance
var response = await applicator.ApplyRulesInProjectPath(projectBasePath);
Customize rule file name:
var generator = new RuleGenerator();
var response = generator.GenerateRules(edmxPath);
if (response.Success)
await generator.SaveRules(projectBasePath, dbContextRulesFile: "DbContextRules.json", response.Rules.First());
Handle log activity:
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 | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.8
- Humanizer.Core (>= 2.14.1)
- Microsoft.Bcl.HashCode (>= 1.1.1)
- Microsoft.Build.Locator (>= 1.5.5)
- Microsoft.CodeAnalysis.Common (>= 4.4.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.4.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.4.0)
- Microsoft.CodeAnalysis.Workspaces.MSBuild (>= 4.4.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 7.0.1)
-
.NETStandard 2.0
- Humanizer.Core (>= 2.14.1)
- Microsoft.Bcl.HashCode (>= 1.1.1)
- Microsoft.Build.Locator (>= 1.5.5)
- Microsoft.CodeAnalysis.Common (>= 4.4.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.4.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.4.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 7.0.1)
-
net6.0
- Humanizer.Core (>= 2.14.1)
- Microsoft.Build.Locator (>= 1.5.5)
- Microsoft.CodeAnalysis.Common (>= 4.4.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.4.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.4.0)
- Microsoft.CodeAnalysis.Workspaces.MSBuild (>= 4.4.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- System.Text.Json (>= 7.0.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on EntityFrameworkRuler.Common:
Package | Downloads |
---|---|
EntityFrameworkRuler.Design
Automatically applies customization of the EF Core Reverse Engineered model during the scaffold process. |
|
EntityFrameworkRuler.Editor
EDMX support for EF Core: Generate customization rules from EF6 EDMX file and apply to EF Core model |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.3.48 | 143 | 9/28/2024 |
1.3.46 | 180 | 8/27/2024 |
1.3.46-alpha.0.1 | 39 | 8/27/2024 |
1.3.45 | 239 | 5/2/2024 |
1.3.44 | 78 | 5/2/2024 |
1.3.43 | 88 | 5/2/2024 |
1.3.42 | 86 | 5/2/2024 |
1.3.40 | 200 | 4/4/2024 |
1.3.9-alpha.0.1 | 61 | 4/4/2024 |
1.3.8 | 201 | 3/21/2024 |
1.3.7 | 188 | 3/21/2024 |
1.3.6 | 560 | 12/19/2023 |
1.3.5 | 452 | 11/29/2023 |
1.3.4 | 439 | 11/18/2023 |
1.2.40 | 567 | 10/26/2023 |
1.2.39 | 453 | 10/25/2023 |
1.2.38 | 424 | 10/24/2023 |
1.2.37 | 439 | 10/23/2023 |
1.2.36 | 910 | 7/17/2023 |
1.2.34-alpha.0.2 | 83 | 7/14/2023 |
1.2.33 | 634 | 7/12/2023 |
1.2.30 | 604 | 6/22/2023 |
1.2.30-alpha.0.1 | 89 | 6/21/2023 |
1.2.29-alpha.0.1 | 71 | 6/20/2023 |
1.2.28 | 665 | 6/20/2023 |
1.2.27 | 1,694 | 4/18/2023 |
1.2.26 | 830 | 3/23/2023 |
1.2.25 | 764 | 3/16/2023 |
1.2.22 | 699 | 3/7/2023 |
1.2.21 | 743 | 3/6/2023 |
1.2.21-alpha.0.4 | 91 | 3/6/2023 |
1.2.19 | 794 | 2/14/2023 |
1.2.19-alpha.0.4 | 98 | 2/14/2023 |
1.2.17 | 783 | 1/31/2023 |
1.2.16 | 855 | 1/27/2023 |
1.2.15 | 790 | 1/27/2023 |
1.2.14 | 814 | 1/26/2023 |
1.2.13 | 823 | 1/25/2023 |
1.2.10 | 842 | 1/25/2023 |
1.2.9 | 817 | 1/25/2023 |
1.2.8 | 788 | 1/25/2023 |
1.2.7 | 799 | 1/24/2023 |
1.2.6 | 806 | 1/24/2023 |
1.2.5 | 722 | 1/24/2023 |
1.2.4 | 701 | 1/18/2023 |
1.2.3 | 755 | 1/17/2023 |
1.2.3-alpha.0.1 | 108 | 1/9/2023 |
1.2.2 | 793 | 1/9/2023 |
1.2.1-alpha.0.2 | 108 | 1/6/2023 |
1.2.0 | 838 | 1/5/2023 |
1.1.8-alpha.0.16.4 | 106 | 1/5/2023 |
1.1.8-alpha.0.16.2 | 118 | 1/5/2023 |
1.1.8-alpha.0.16.1 | 116 | 1/5/2023 |
1.1.8-alpha.0.16 | 117 | 1/5/2023 |
1.1.8-alpha.0.15 | 114 | 1/4/2023 |
1.1.7 | 867 | 12/14/2022 |
1.1.6-alpha.0.5 | 97 | 12/14/2022 |
1.1.6-alpha.0.4 | 97 | 12/13/2022 |
1.1.6-alpha.0.2 | 101 | 12/13/2022 |
1.1.6-alpha.0.1 | 93 | 12/13/2022 |
1.1.5 | 863 | 12/9/2022 |
1.1.3 | 834 | 12/8/2022 |
1.1.3-alpha.0.2 | 95 | 12/8/2022 |
1.1.3-alpha.0.1 | 97 | 12/8/2022 |
1.1.2 | 849 | 12/8/2022 |
1.1.1 | 795 | 12/7/2022 |
1.1.0 | 822 | 12/6/2022 |
1.0.29-alpha.0.50 | 105 | 12/6/2022 |
1.0.29-alpha.0.48 | 98 | 12/6/2022 |
1.0.29-alpha.0.44 | 96 | 12/6/2022 |
1.0.28 | 865 | 11/18/2022 |
1.0.27 | 884 | 11/18/2022 |
1.0.26 | 866 | 11/18/2022 |
1.0.25 | 820 | 11/18/2022 |
1.0.22 | 876 | 11/17/2022 |
1.0.21 | 914 | 11/17/2022 |
1.0.20 | 896 | 11/16/2022 |
1.0.19 | 870 | 11/16/2022 |
1.0.18 | 854 | 11/16/2022 |
1.0.16 | 858 | 11/15/2022 |
1.0.13 | 865 | 11/15/2022 |