![]() |
VOOZH | about |
dotnet add package AspNet.Module.Migrator --version 3.0.1
NuGet\Install-Package AspNet.Module.Migrator -Version 3.0.1
<PackageReference Include="AspNet.Module.Migrator" Version="3.0.1" />
<PackageVersion Include="AspNet.Module.Migrator" Version="3.0.1" />Directory.Packages.props
<PackageReference Include="AspNet.Module.Migrator" />Project file
paket add AspNet.Module.Migrator --version 3.0.1
#r "nuget: AspNet.Module.Migrator, 3.0.1"
#:package AspNet.Module.Migrator@3.0.1
#addin nuget:?package=AspNet.Module.Migrator&version=3.0.1Install as a Cake Addin
#tool nuget:?package=AspNet.Module.Migrator&version=3.0.1Install as a Cake Tool
Database migration package for applying EF Core migrations and running seed data.
public class MigrationDbContext : AppDbContext
{
}
Microsoft.EntityFrameworkCore.DesignThis enables dotnet ef migrations add and other EF Core CLI commands.
<ItemGroup>
<PackageReference Include="AspNet.Module.Migrator" Version="3.x.x" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
public class MigrationDbContextFactory : BaseDesignTimeDbContextFactory<MigrationDbContext>
{
}
dotnet ef migrations add Init
dotnet ef migrations remove
Programvar migrator = new AspNetMigrator<MigrationDbContext>(new AspNetMigratorOptions(args)
{
Configuration = c =>
{
#if DEBUG
c.AddUserSecrets(Assembly.GetEntryAssembly());
#endif
}
});
migrator.Seeds.Add<Seed1>();
migrator.Seeds.Add<Seed2>();
await migrator.RunAsync();
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
RUN dotnet restore src/Some.Migrator/*.csproj
WORKDIR /app/src/Some.Migrator
RUN dotnet publish -o out -c Release --no-restore
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
COPY --from=build /app/src/Some.Migrator/out ./migrate/
internal class SomeSeed : ISeedDatabaseExecutor<MigrationDbContext>
{
public int Order => 1;
public string Name => nameof(SomeSeed);
public bool Enabled => true;
public Task Execute(MigrationDbContext dbContext, CancellationToken ct)
{
dbContext.SomeEntity.Add(...);
return Task.CompletedTask;
}
}
var migrator = new AspNetMigrator<MigrationDbContext>(new ConsoleMigratorConfig(...));
migrator.Seeds.Add<SomeSeed>();
await migrator.RunAsync();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.