EF.Extensions.PgCopy 1.0.0

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

// Install EF.Extensions.PgCopy as a Cake Tool
#tool nuget:?package=EF.Extensions.PgCopy&version=1.0.0                

Ef Core postgres COPY binary extension

Entity framwork core extension to perform Postgres copy

Based on PostgreSQLCopyHelper

Postgres Copy command

Preview of use

var options = new DbContextOptionsBuilder<BloggingContext>()
                .UseNpgsql(ConnectionString, opt => opt.CommandTimeout((int) TimeSpan.FromMinutes(1).TotalSeconds))
                .Options;

await using var dbContext = new BloggingContext(options);
await dbContext.Posts.AddRangeAsync(posts, cancellationToken);
await dbContext.Blogs.AddRangeAsync(blogs, cancellationToken);

# classic use with multiple Insert sql commands
if (!byCopy) return await dbContext.SaveChangesAsync(cancellationToken);

# function based on Postgres Copy command
var result = await dbContext.SaveByCopyChangesAsync(cancellationToken);

Benchmark


BenchmarkDotNet=v0.12.1, OS=macOS Catalina 10.15.4 (19E287) [Darwin 19.4.0]
Intel Core i7-9750H CPU 2.60GHz, 1 CPU, 12 logical and 6 physical cores
.NET Core SDK=3.1.201
  [Host]     : .NET Core 3.1.3 (CoreCLR 4.700.20.11803, CoreFX 4.700.20.12001), X64 RyuJIT
  DefaultJob : .NET Core 3.1.3 (CoreCLR 4.700.20.11803, CoreFX 4.700.20.12001), X64 RyuJIT


Method count Mean Error StdDev
Save 100 42.51 ms 1.281 ms 3.736 ms
SaveEfCopy 100 24.65 ms 1.160 ms 3.327 ms
Save 100000 26,117.05 ms 739.131 ms 2,156.079 ms
SaveEfCopy 100000 9,157.41 ms 410.181 ms 1,196.518 ms

TODO

  • Test Multi entities tracking (SaveByCopyChanges)
  • mixing saving entities with saveChanges and SaveByCopyChanges functions at the same time
  • Auto load from NpgsqlDbType and BuiltInPostgresType attribute
  • Get DBConnection from dbContext.Database
  • Test with different column types
  • BenchMark COPY vs multi insert methods
  • Caching PostgreSQLCopyHelperFactory
  • SaveCopyChanges extension
  • Transaction handling
  • Unit tests
  • Packaging library
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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.