E.EntityFrameworkCore.Extensions 0.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package E.EntityFrameworkCore.Extensions --version 0.0.5                
NuGet\Install-Package E.EntityFrameworkCore.Extensions -Version 0.0.5                
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="E.EntityFrameworkCore.Extensions" Version="0.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add E.EntityFrameworkCore.Extensions --version 0.0.5                
#r "nuget: E.EntityFrameworkCore.Extensions, 0.0.5"                
#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.
// Install E.EntityFrameworkCore.Extensions as a Cake Addin
#addin nuget:?package=E.EntityFrameworkCore.Extensions&version=0.0.5

// Install E.EntityFrameworkCore.Extensions as a Cake Tool
#tool nuget:?package=E.EntityFrameworkCore.Extensions&version=0.0.5                

E.EntityFrameworkCore.Extensions


EntityFrameworkCore 的扩展库

NuGet Version

NuGet Downloads

功能


目前已经实现的功能

  • PostgreSql DbSet和 DbQeruy 表名、视图名、列名自动处理为小写
  • Oracle DbSet 和 DbQuery 表名、视图名、列名自动处理为大写
  • 自定义 DbSet 校验处理函数
  • 自定义 DbQuery 校验处理函数
  • 自定义 Column(Field) 校验处理函数
  • 自定义列名长度,自动进行裁剪
  • 自动跳过处理 DbContext 程序集中已实现的 IEntityTypeConfiguration 和 IQueryTypeConfiguration

基本用法

1. 引入nuget包

  • dotnet cli

dotnet add package E.EntityFrameworkCore.Extensions

  • nuget package manager

Install-Package E.EntityFrameworkCore.Extensions

2. 配置 DbContext

  • 重写 DbContext的 OnModelCreating 函数
  • 引入命名空间 using E;

3. 配置 E.EntityFrameworkCore.Extensions

以下代码均处于 OnModelCreating 函数中

PostgreSql

  base.OnModelCreating(modelBuilder);
  
  // 设置转大写为false
  E.EntityFrameworkCoreTableViewExtensions.UseUpperCase = false;
  
  // 增加映射的字段类型字符串, 由于 PostgreSql 支持数据类型过于丰富,此处省略部分...
  E.EntityFrameworkCoreTableViewExtensions.DbMapTypes.Add("System.String[]");
  E.EntityFrameworkCoreTableViewExtensions.DbMapTypes.Add("System.Boolean[]");
  E.EntityFrameworkCoreTableViewExtensions.DbMapTypes.Add("System.Int32[]");
  
  // 将名为 YourContext 中的所有 DbSet 和 DbQuery 的表名、视图名、列名转换为小写
  // 参数位 true,则 自动跳过处理 DbContext 程序集中已实现的 IEntityTypeConfiguration 和 IQueryTypeConfiguration
  modelBuilder.SetAllDbSetTableNameAndColumnName<YourContext>(/* true */);
  modelBuilder.SetAllDbQueryViewNameAndColumnName<YourContext>(/* true */);

Oracle

  base.OnModelCreating(modelBuilder);
  
  // 设置转大写为 true
  E.EntityFrameworkCoreTableViewExtensions.UseUpperCase = true;
  
  // 设置字段类型为字符串的默认长度(因为oracle限制字符串最大长度为2000),若字段标记 StringLength 则取 StringLength 长度
  E.EntityFrameworkCoreTableViewExtensions.UseDefaultStringMaxLength = true;
  E.EntityFrameworkCoreTableViewExtensions.DefaultStringMaxLength = 256;
  
  // 启用限制列名长度,超出长度自动裁剪(因为oracle限制列名最大长度为30)
  E.EntityFrameworkCoreTableViewExtensions.UseColumnNameMaxLength = true;
  E.EntityFrameworkCoreTableViewExtensions.ColumnNameMaxLength = 30;
  
  // 将名为 YourContext 中的所有 DbSet 和 DbQuery 的表名、视图名、列名转换为大写
  // 参数位 true,则 自动跳过处理 DbContext 程序集中已实现的 IEntityTypeConfiguration 和 IQueryTypeConfiguration
  modelBuilder.SetAllDbSetTableNameAndColumnName<YourContext>(/* true */);
  modelBuilder.SetAllDbQueryViewNameAndColumnName<YourContext>(/* true */);

自定义校验处理函数

以下代码均处于 OnModelCreating 函数中

  // DbSet Check
  E.EntityFrameworkCoreTableViewExtensions.DbSetCheck = (info) =>
  {
      // 你的校验逻辑
      return true;// or false
  };
  
  // DbQuery Check
  E.EntityFrameworkCoreTableViewExtensions.DbQueryCheck = (info) =>
  {
      // 你的校验逻辑
      return true;// or false
  };
  
  // Column Chcek
  E.EntityFrameworkCoreTableViewExtensions.ColumnCheck = (info) =>
  {
      // 你的校验逻辑
      return true;// or false
  };

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.0 1,688 7/7/2020
0.0.8 3,885 5/16/2019
0.0.7 538 5/16/2019
0.0.5 1,382 5/8/2019
0.0.4 553 5/7/2019
0.0.3 554 5/7/2019
0.0.2 544 5/7/2019
0.0.1 548 5/7/2019