Bước 2: Gõ các lệnh sau:
Enable-Migrations
----
This command has added a Migrations folder to our project, this new folder contains two files:
- The Configuration class. This class allows you to configure how Migrations behaves for your context. For this walkthrough we will just use the default configuration. Because there is just a single Code First context in your project, Enable-Migrations has automatically filled in the context type this configuration applies to.
- An InitialCreate migration. This migration was generated because we already had Code First create a database for us, before we enabled migrations. The code in this scaffolded migration represents the objects that have already been created in the database. In our case that is the Blog table with a BlogId and Name columns. The filename includes a timestamp to help with ordering. If the database had not already been created this InitialCreate migration would not have been added to the project. Instead, the first time we call Add-Migration the code to create these tables would be scaffolded to a new migration.
--
will scaffold the next migration based on changes you have made to your model since the last migration was created.
Update-Database
--
will apply any pending migrations to the database.
Không có nhận xét nào:
Đăng nhận xét