EntityFrameworkCore Automatic Migrations NuGet Package

Entity Framework Core Automatic Migrations allows you to use code first migrations without having a code file in your project for each change you make.
How to use:
/// Migrations Options
public class DbMigrationsOptions
{
/// <summary>
/// Allow auto migration with data lost
///
</summary>
public bool AutomaticMigrationDataLossAllowed { get; set; } = false;
/// <summary>
/// Enable to execute auto migration
///
</summary>
public bool AutomaticMigrationsEnabled { get; set; } = true;
/// <summary>
/// Drop all tables from database and recreate based on model snapshot.

Useful in scenarios when the data is transient and can be dropped when the schema changes. For example during prototyping, in tests, or for local changes.
///
</summary>
public bool ResetDatabaseSchema { get; set; } = false;

/// <summary>
/// Allow to update snapshot.The key will pe replaced with value for each KeyValuePair
///
</summary>
public Dictionary<![CDATA[string, string]]> UpdateSnapshot { get; set; } = new Dictionary<![CDATA[string, string]]>;
}

Option 1 (using method):
MigrateDatabaseToLatestVersion.Execute(context);
MigrateDatabaseToLatestVersion.Execute(context, new DbMigrationsOptions { ResetDatabaseSchema = true });

Option 2 (using context extension)
context.MigrateToLatestVersion();
context.MigrateToLatestVersion(new DbMigrationsOptions { ResetDatabaseSchema = true });.




Got any EntityFrameworkCore Automatic Migrations Question?





Info

Version: 8.0.5
Author(s): Ionut Neagos
Last Update: Sunday, May 19, 2024
.NET Fiddle: Create the first Fiddle
Project Url: https://github.com/ionutneagos/efcore-automaticmigrations
NuGet Url: https://www.nuget.org/packages/EFCore.AutomaticMigrations


Install
Install-Package EFCore.AutomaticMigrations
dotnet add package EFCore.AutomaticMigrations
paket add EFCore.AutomaticMigrations
EFCore.AutomaticMigrations Download (Unzip the "nupkg" after downloading)



Tags



STATS

must-have-score

.3

avg-downloads-per-day

30

days-since-last-release

32