EfCore.InMemoryHelpers 1.9.0

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

// Install EfCore.InMemoryHelpers as a Cake Tool
#tool nuget:?package=EfCore.InMemoryHelpers&version=1.9.0

EfCore.InMemoryHelpers

Actively Maintained Build status NuGet Status

Provides a wrapper around the EF Core In-Memory Database Provider. Specifically works around the following EF bugs.

  • InMemory: Improve in-memory key generation <br> Reasoning: For many bootstrapping and integration tests, the id generation should be predictable, i.e. an in-memory persistence should not share static mutable state. This is especially important when using unit tests as a bootstrap to generate ad-hoc data.
  • Add index validation<br> Reasoning: It is desirable for indexes to be validated when running unit tests. This allows bugs to be caught earlier without the need for integration testing against a real database.
  • Add support for Timestamp/row version ([Timestamp], and .Property(p => p.X).IsRowVersion())<br> Reasoning: It is desirable for exceptions to be thrown when a update violates a RowVersion. This allows bugs to be caught earlier without the need for integration testing against a real database.

This project is supported by the community via Patreon sponsorship. If you are using this project to deliver business value or build commercial software it is expected that you will provide support via Patreon.

NuGet

https://nuget.org/packages/EfCore.InMemoryHelpers/

PM> Install-Package EfCore.InMemoryHelpers

Usage

The main entry point is InMemoryContextBuilder which can be used to build an in-memory context.

using (var context = InMemoryContextBuilder.Build<MyDataContext>())
{
    var entity = new MyEntity
    {
        Property = "prop"
    };
    context.Add(entity);
    context.SaveChanges();
}

A custom DbContextOptionsBuilder can be passed in:

var builder = new DbContextOptionsBuilder<MyDataContext>();
using (var context = InMemoryContextBuilder.Build<MyDataContext>(builder))
{
    var entity = new MyEntity
    {
        Property = "prop"
    };
    context.Add(entity);
    context.SaveChanges();
}

Both the above usages assume that the target context has a public constructor that accepts a DbContextOptions.

public MyDataContext(DbContextOptions options)
    :
    base(options)
{ }

If this is not the case a custom context constructor can be passed in:

var builder = new DbContextOptionsBuilder<MyDataContext>();
using (var context = InMemoryContextBuilder.Build(builder, options => new MyDataContext(options)))
{
    var entity = new MyEntity
    {
        Property = "prop"
    };
    context.Add(entity);
    context.SaveChanges();
}

Icon

<a href="https://thenounproject.com/term/memory/884922/" target="_blank">memory</a> designed by Montu Yadav from The Noun Project

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
1.9.11 44,243 9/17/2019
1.9.3 533 9/17/2019
1.9.1 477 9/17/2019
1.9.0 477 9/17/2019
1.8.0 12,048 3/13/2019