Entity Framework常用命令

Entity Framework常用命令

  • Enable-Migrations 启用Migration数据迁移
  • Add-Migration migrationname 为挂起的Model变化添加迁移脚本
  • Update-Database –TargetMigration:migrationname 回滚到指定数据库
  • Update-Database 将挂起的迁移更新到数据库
  • Update-Database -Script -SourceMigration: $InitialDatabase -TargetMigration: AddPostAbstract 生产迁移sql脚本
  • get-help Update-Database -detailed查看Add-Migration的详细用法。

若要查看示例,请键入: "get-help Update-Database -examples".
有关详细信息,请键入: "get-help Update-Database -detailed".
若要获取技术信息,请键入: "get-help Update-Database -full".


 -------------------------- 示例 1 --------------------------
  
   Update-Database
    
    # Update the database to the latest migration
        
    
    
    -------------------------- 示例 2 --------------------------
    
    Update-Database -TargetMigration Second
    
    # Update database to a migration named "Second"
    # This will apply migrations if the target hasn't been applied or roll back migration
    s
    # if it has
        
    
    
    -------------------------- 示例 3 --------------------------
    
    Update-Database -Script
    
    # Generate a script to update the database from it's current state  to the latest mig
    ration
        
    
    
    -------------------------- 示例 4 --------------------------
    
    Update-Database -Script -SourceMigration Second -TargetMigration First
    
    # Generate a script to migrate the database from a specified start migration
    # named "Second" to a specified target migration named "First"
       
    
    
    -------------------------- 示例 5 --------------------------
    
    Update-Database -Script -SourceMigration $InitialDatabase
    
    # Generate a script that can upgrade a database currently at any version to the lates
    t version. 
    # The generated script includes logic to check the __MigrationsHistory table and only
     apply changes 
    # that haven't been previously applied.
        
    
    
    -------------------------- 示例 6 --------------------------
    
    Update-Database -TargetMigration $InitialDatabase
    
    # Runs the Down method to roll-back any migrations that have been applied to the data
    base
                   
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值