zoukankan      html  css  js  c++  java
  • EF Code First Migrations数据库迁移

    VS工具->Nuget包管理器->程序包管理控制台

    执行以下命名:

    PM> enable-migrations
      More than one context type was found in the assembly 'DataMigration'.
      To enable migrations for 'DataMigration.PrivateDb', use Enable-Migrations -ContextTypeName DataMigration.PrivateDb.
      To enable migrations for 'DataMigration.PublicDb', use Enable-Migrations -ContextTypeName DataMigration.PublicDb.
      To enable migrations for 'DataMigration.RKEDb', use Enable-Migrations -ContextTypeName DataMigration.RKEDb.

    PM> enable-migrations -ContextTypeName DataMigration.PrivateDb

      Checking if the context targets an existing database...
      Code First Migrations enabled for project DataMigration.


    PM> Add-Migration InitialCreate
      Scaffolding migration 'InitialCreate'.
      The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to   include in this migration, then you can re-scaffold it by running 'Add-Migration InitialCreate' again.


    PM> Update-Database -Verbose
      Using StartUp project 'DataMigration'.
      Using NuGet project 'DataMigration'.
      Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
      Target database is: 'TC_Private' (DataSource: ., Provider: System.Data.SqlClient, Origin: Configuration).
      Applying explicit migrations: [201906180146102_InitialCreate].
      Applying explicit migration: 201906180146102_InitialCreate.
      CREATE TABLE [dbo].[T_MT_Community] (
        [Id] [nvarchar](128) NOT NULL,
        [MigrationTime] [datetime] NOT NULL,
        CONSTRAINT [PK_dbo.T_MT_Community] PRIMARY KEY ([Id])
      ) 
      INSERT [dbo].[__MigrationHistory]([MigrationId], [ContextKey], [Model], [ProductVersion])
      VALUES (.............................)

      Running Seed method.

  • 相关阅读:
    关于OPC自动化接口编程(OPCDAAuto.dll)几点注意问题
    OPCDAAuto.dll的C#使用方法浅析(转载)
    微软系统工具包Sysinternals Suite官方下载地址
    C#的dll被其他程序调用时,获取此dll正确的物理路径
    根据存储过程,查询此过程的参数和参数数据类型讯息
    sql server中类似oracle中decode功能的函数
    c# HttpWebResponse 调用WebApi
    MariaDB10.4以上版本安装
    Windows server 2012 显示“我的电脑”
    Debian 9 启动后进入命令行
  • 原文地址:https://www.cnblogs.com/intotf/p/11043939.html
Copyright © 2011-2022 走看看