EfCore.TestSupportSchema 1.0.0-preview002

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

// Install EfCore.TestSupportSchema as a Cake Tool
#tool nuget:?package=EfCore.TestSupportSchema&version=1.0.0-preview002&prerelease

TestSupportSchema

This is a TEMPERARY project (it will move into EfCore.TestSupport when EF Core 5 is released) to contain the method EnsureClean which wipes the database schema and replaces it with a database that matches the current DbContext's configuration.

Why is this useful?

When you are writing your unit tests you are likely to use the command context.Database.EnsureCreated() to set up the database you use for unit testing. That works for Sqlite in-memory databases, but it you are using a real database, then you need to call below to make sure that the database schema is up to date

context.Database.EnsureDeleted();
context.Database.EnsureCreated();

The problem is the EnsureDeleted/EnsureCreated calls take a LONG time. This feature has the same effect (e.g. correct schema, empty of data) but is MUCH quicker e.g. for a very small database the timings are:

What First use Second use
EnsureDeleted/EnsureCreated 10 secs. 10 secs.
EnsureClean 300 ms 30 ms
Respawn (see note below) 170 ms 35 ms

NOTE: Respawn is a NuGet library that removes all the rows in all the tables in a database. Useful if you have already called EnsureClean on the database and just want to remove the rows.*

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.

Version Downloads Last updated
5.0.0-preview001 561 9/21/2020
1.0.0-preview003 339 5/19/2020
1.0.0-preview002 286 5/18/2020
1.0.0-preview001 296 5/18/2020

Preview version for testing. This feature will be added to EfCore.TestSupport when that library is updated to EF Core 5.