zoukankan      html  css  js  c++  java
  • EF Core 迁移整理

    EF Core 迁移整理

    PowerShell
    Add-Migration InitialCreate
    
    多数据源
    Add-Migration InitialCreate -Context MyDbContext -OutputDir MigrationsSqlServerMigrations
    Add-Migration InitialCreate -Context MySqliteDbContext -OutputDir MigrationsSqliteMigrations
    
    Console
    dotnet ef migrations add InitialCreate
    
    dotnet ef migrations add InitialCreate --context MyDbContext --output-dir Migrations/SqlServerMigrations
    dotnet ef migrations add InitialCreate --context MySqliteDbContext --output-dir Migrations/SqliteMigrations

    更新数据库

    PowerShell
    Update-Database
    
    Console
    dotnet ef database update

    删除迁移

    PowerShell
    Remove-Migration
    
    Console
    dotnet ef migrations remove

    还原迁移

    PowerShell
    Update-Database LastGoodMigration
    
    Console
    dotnet ef database update LastGoodMigration

    生成迁移Sql

    PowerShell
    Script-Migration
    Script-Migration -From migrationName1 -To migrationName2  -Context ContextName
    
    Console
    dotnet ef migrations script
    dotnet ef migrations script -From migrationName1 -To migrationName2  -Context ContextName

    迁移脚本的帮助说明

    我们可以通过命令来获取帮助说明
    Get
    -Help about_EntityFrameworkCore get-help Add-Migration -full get-help Script-Migration -full
  • 相关阅读:
    SRM 441(1-250pt, 1-500pt)
    SRM 387(1-250pt)
    SRM 388(1-250pt)
    SRM 389(1-250pt)
    SRM 601(1-250pt,500pt)
    SRM 409(1-250pt, 1-500pt)
    SRM 408(1-250pt, 1-500pt)
    unique() 去重函数
    poj3468(A Simple Problem with Integers)
    HDU1394(Minimum Inversion Number)
  • 原文地址:https://www.cnblogs.com/netcs/p/13402692.html
Copyright © 2011-2022 走看看