EntityFrameworkCore.AutoMigration 1.0.0

dotnet add package EntityFrameworkCore.AutoMigration --version 1.0.0
                    
NuGet\Install-Package EntityFrameworkCore.AutoMigration -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="EntityFrameworkCore.AutoMigration" Version="1.0.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EntityFrameworkCore.AutoMigration" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="EntityFrameworkCore.AutoMigration">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
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 EntityFrameworkCore.AutoMigration --version 1.0.0
                    
#r "nuget: EntityFrameworkCore.AutoMigration, 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.
#addin nuget:?package=EntityFrameworkCore.AutoMigration&version=1.0.0
                    
Install EntityFrameworkCore.AutoMigration as a Cake Addin
#tool nuget:?package=EntityFrameworkCore.AutoMigration&version=1.0.0
                    
Install EntityFrameworkCore.AutoMigration as a Cake Tool

Auto migration for EntityFrameworkCore8.0+,only relational databases are supported.

Usage

1. Enable auto migration

Just call extension method DbContextOptionsBuilder.UseAutoMigration() to enable auto migration.

services.AddDbContext<MyDbContext>(options =>
{
    options.UseNpgsql("Host=;Username=;Password=;Database=");
    options.UseAutoMigration();
});

or

public class MyDbContext : DbContext
{
   protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
   {
        base.OnConfiguring(optionsBuilder);
        optionsBuilder.UseAutoMigration();
    }
}

2. Execute migration

Must call DatabaseFacade.AutoMigrate() or DatabaseFacade.AutoMigrateAsync() to execute migration.

var ctx = _serviceProvider.GetRequiredService<MyDbContext>();
await ctx.Database.AutoMigrateAsync();

Or

var ctx = _serviceProvider.GetRequiredService<MyDbContext>();
await ctx.GetService<IRelationalAutoMigrator>().MigrateAsync();

3. Other useful methods

var ctx = _serviceProvider.GetRequiredService<MyDbContext>();
var migrations = ctx.Database.GetMigrations();// get migrations of current dbcontext model.
var migrations = await ctx.Database.GetAppliedMigrationsAsync();// get migrations of applied dbcontext model.
var migrations = await ctx.Database.GetPendingMigrationsAsync();// get migrations of pending dbcontext model.
Product 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.

This package has no dependencies.

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.0.0 150 4/20/2025