Aicrosoft.DataAccess.DbMigration 8.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Aicrosoft.DataAccess.DbMigration --version 8.3.0                
NuGet\Install-Package Aicrosoft.DataAccess.DbMigration -Version 8.3.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="Aicrosoft.DataAccess.DbMigration" Version="8.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aicrosoft.DataAccess.DbMigration --version 8.3.0                
#r "nuget: Aicrosoft.DataAccess.DbMigration, 8.3.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.
// Install Aicrosoft.DataAccess.DbMigration as a Cake Addin
#addin nuget:?package=Aicrosoft.DataAccess.DbMigration&version=8.3.0

// Install Aicrosoft.DataAccess.DbMigration as a Cake Tool
#tool nuget:?package=Aicrosoft.DataAccess.DbMigration&version=8.3.0                

DbMigration.Core

引用该类库,继承 DbContextFactory<T> 后

How To Use

  1. Migration and update database 不必是在可启动的项目里,只要是在有DbContext的项目中即可。
# Install
dotnet tool install --global dotnet-ef

# update
dotnet tool update --global dotnet-ef

# cd the project dir
## 专门用于迁移Sqliter的Client端
cd W:\Aicrosoft\ProjectTemplates\DbMigrations\DbMigrator

# use the tools on a specific project || 用Nuget包安装到你想生成的项目里
# 注意:版本必须与DbContext引用的版本一致。
dotnet add package Microsoft.EntityFrameworkCore.Design -v 8.0.7
# Install-Package Microsoft.EntityFrameworkCore.Design -Version 8.0.7

# add migration
## 创建一个新的迁移脚本,记录当前模型与数据库之间的差异。
dotnet ef migrations add Init -c UserDbContext -o Migrations\SqliteUserDb
dotnet ef migrations add Init -c SqliteUsershipDbContext

dotnet ef migrations remove --context SqliteUsershipDbContext
## 指定SqliteSampleDbContext所在的项目程序集
# dotnet ef migrations add Init --context SqliteSampleDbContext --project SqliteDbSampleJob --startup-project DbSampeMigrator


# Updates the database to the last migration or to a specified migration.
## 将所有未应用的迁移应用到数据库上。
dotnet ef database update -c SqliteUsershipDbContext


## 显示所有可用的迁移,包括已应用和未应用的迁移。
dotnet ef migrations list --context SqliteUsershipDbContext

## 回滚最近应用的迁移。
dotnet ef database update <MigrationName>

## 生成SQL脚本来创建数据库和所有迁移。
dotnet ef migrations script --context SqliteSampleDbContext


## 清除所有迁移,将模型重置为初始状态。
dotnet ef migrations remove


## 显示当前使用的数据库上下文
dotnet ef dbcontext info --context SqliteSampleDbContext

## 列出项目中所有可用的数据库上下文
dotnet ef dbcontext list

## 设置要使用的数据库上下文
dotnet ef dbcontext set <DbContextClassName>

## 更新数据库以匹配模型的状态。
dotnet ef database update

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.5.0 90 10/12/2024
8.3.0 108 9/10/2024