Wolfgang.DbContextBuilder-Core-EF6
0.3.3
dotnet add package Wolfgang.DbContextBuilder-Core-EF6 --version 0.3.3
NuGet\Install-Package Wolfgang.DbContextBuilder-Core-EF6 -Version 0.3.3
<PackageReference Include="Wolfgang.DbContextBuilder-Core-EF6" Version="0.3.3" />
<PackageVersion Include="Wolfgang.DbContextBuilder-Core-EF6" Version="0.3.3" />
<PackageReference Include="Wolfgang.DbContextBuilder-Core-EF6" />
paket add Wolfgang.DbContextBuilder-Core-EF6 --version 0.3.3
#r "nuget: Wolfgang.DbContextBuilder-Core-EF6, 0.3.3"
#:package Wolfgang.DbContextBuilder-Core-EF6@0.3.3
#addin nuget:?package=Wolfgang.DbContextBuilder-Core-EF6&version=0.3.3
#tool nuget:?package=Wolfgang.DbContextBuilder-Core-EF6&version=0.3.3
DbContextBuilder
Uses the Builder pattern to create Entity Framework Core and classic DbContext instances
using an in-memory database for testing purposes. With DbContextBuilder, you can easily set up
a DbContext with predefined data, making it ideal for unit tests and integration tests without
having to rely on an actual database whose data can be changed or deleted over time
Features
Create DbContext instances with an in-memory database. By default, DbContextBuilder uses the Sqlite in-memory database provider. However, you can use other databases by passing in your own
DbConnection.Add your own data to the DbContext using the
SeedWith<T>methodEasily add random data using the
SeedWithRandom<T>method. This method will create random data in your database to simulate real-world scenarios where a database will have more than just the data you seed with.
Installation
You can install the DbContextBuilder package via NuGet. Run the following command in the Package Manager Console:
Install-Package Wolfgang.DbContextBuilder
Usage
Here's a simple example of how to use DbContextBuilder to create a DbContext with seeded data:
// Create a DbContext with seeded random data and your test data
var context = new DbContextBuilder<YourDbContext>()
// Seed with 10 random entities
.SeedWithRandom<YourEntity>(10)
// Seed with specific data
.SeedWith
(
new YourEntity
{
Id = 1,
Name = "Test Entity"
}
)
// Seed with 5 random entities
.SeedWithRandom<YourEntity>(5)
// Build the DbContext instance
.Build();
// Use the context in your tests
var sut = new YourService(context);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- AutoFixture (>= 4.18.1)
- Microsoft.EntityFrameworkCore (>= 6.0.36 && < 7.0.0)
- Microsoft.EntityFrameworkCore.InMemory (>= 6.0.36 && < 7.0.0)
- Microsoft.EntityFrameworkCore.Sqlite (>= 6.0.36 && < 7.0.0)
- System.Net.Http (>= 4.3.4)
- System.Text.RegularExpressions (>= 4.3.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.