Aicrosoft.DataAccess.DbMigration
8.0.0-beta.260127.1
This is a prerelease version of Aicrosoft.DataAccess.DbMigration.
dotnet add package Aicrosoft.DataAccess.DbMigration --version 8.0.0-beta.260127.1
NuGet\Install-Package Aicrosoft.DataAccess.DbMigration -Version 8.0.0-beta.260127.1
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="Aicrosoft.DataAccess.DbMigration" Version="8.0.0-beta.260127.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aicrosoft.DataAccess.DbMigration" Version="8.0.0-beta.260127.1" />
<PackageReference Include="Aicrosoft.DataAccess.DbMigration" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Aicrosoft.DataAccess.DbMigration --version 8.0.0-beta.260127.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Aicrosoft.DataAccess.DbMigration, 8.0.0-beta.260127.1"
#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.
#:package Aicrosoft.DataAccess.DbMigration@8.0.0-beta.260127.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Aicrosoft.DataAccess.DbMigration&version=8.0.0-beta.260127.1&prerelease
#tool nuget:?package=Aicrosoft.DataAccess.DbMigration&version=8.0.0-beta.260127.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Aicrosoft.DataAccess.DbMigration
Aicrosoft.DataAccess.DbMigration is a utility library for Entity Framework Core that provides a standardized base for design-time DbContext creation. It simplifies the setup required for EF Core Migration tools by leveraging the standard .NET Generic Host patterns.
Design Goals
- Standardized Design-Time Factory: Provides the
DbContextFactory<TDbContext>base class, which implementsIDesignTimeDbContextFactory<TDbContext>. - Configuration-Driven: Automatically loads configuration from
appsettings.jsonand environment variables during the migration process, ensuring consistency between runtime and design-time environments. - Dependency Injection Support: Utilizes
IHostBuilderto allow the use of DI and other framework services duringDbContextinitialization. - Simplified Boilerplate: Encapsulates the logic for building
DbContextOptions, allowing developers to focus solely on provider-specific configuration (e.g., SQL Server vs SQLite). - Environment Awareness: Supports different configurations for different hosting environments (Development, Staging, Production).
Key Components
DbContextFactory<TDbContext>: An abstract base class that sets up a full host environment to resolve theDbContext. You only need to implement theUseDbServermethod.
Usage
1. Installation
Ensure your migration project has references to:
Aicrosoft.DataAccess.DbMigrationMicrosoft.EntityFrameworkCore.Design(must match your EF Core version)
2. Implement the Factory
Create a class in your migration project that inherits from DbContextFactory<T>.
using Aicrosoft.DataAccess;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace MyProject.Migrations;
public class MyDbContextFactory : DbContextFactory<MyDbContext>
{
protected override void UseDbServer(HostBuilderContext hostBuilderContext, IServiceCollection services)
{
// Get connection string from appsettings.json loaded by the base class
var connectionString = hostBuilderContext.Configuration.GetConnectionString("DefaultConnection");
// Set up the DB provider on the internal DbOptionBuilder
DbOptionBuilder.UseSqlServer(connectionString, b =>
{
// Specify the assembly where migrations are located if different from the DbContext assembly
b.MigrationsAssembly(MigratorAssemblyName);
});
}
}
3. CLI Commands
Navigate to your migration project directory and use standard dotnet ef commands:
# Add a new migration
dotnet ef migrations add InitialCreate --context MyDbContext
# Update the database
dotnet ef database update --context MyDbContext
Notes
appsettings.json: The factory expects anappsettings.jsonfile in the project root to read connection strings and other settings.- Sensitive Data: By default,
EnableSensitiveDataLoggingandEnableDetailedErrorsare enabled in the factory for easier debugging during development.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Aicrosoft.DataAccess.EntityFrameworkCore (>= 8.0.0-beta.260127.1)
- Aicrosoft.Extensions.Hosting (>= 8.0.0-beta.260127.1)
- Aicrosoft.Extensions.NLog (>= 8.0.0-beta.260127.1)
- Microsoft.EntityFrameworkCore (>= 8.0.14)
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 |
|---|---|---|
| 8.0.0-beta.260127.1 | 5 | 1/27/2026 |
| 8.0.0-beta.251110.1 | 184 | 11/10/2025 |