"EF Code First" migrations Database migration

Source: Internet
Author: User

1. Open Tool->nuget Program Manager, Package Manager console

The project where the data access context class is to be selected in the default project

My db is under the namespace Codefirst.ui, so choose Codefirst.ui

 

Then execute enable-migrations

If it fails, there is an error that warns you that you are not installing XXXX or missing xxxx (once, the error message is not retained, the next time you have a chance to add),

Need to install

(I don't know what the hell it is);

To the official Web download installation can be http://www.microsoft.com/zh-cn/download/details.aspx?id=30671

If successful, there will be one more folder in the project migrations

2, execute add-migration * * *; the asterisk is a name for this migration

Pm> add-migration useraddfiled

3, execute Update-database

"EF Code First" migrations Database migration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.