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.

转载于:https://www.cnblogs.com/intotf/p/11043939.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值