EF6 using Codefirst Total review in the original database (Iv. new entity object)

Source: Internet
Author: User

Use Codefirst in an existing database, except for the first time you add an entity to do it immediately

Enable-migrations

Add-migration initial-ignorechanges

Update-database

, the others are the same as the new database, and the changes are performed

Add-migration newmodify

Update-database

Note: Generate all the original tables, otherwise it seems that it is not as easy as the database first to add directly.

First, add a new entity class

Because it is code first, some features are added directly, and the fields are for testing only and not complete.

Added a primary foreign key relationship to the post entity (POST).

Accordingly, the post entity needs to be modified:

Second, data migration (can also be set to automatic migration, but for me this rookie manual migration more sense of accomplishment:)

Add-migration AddUser

Update-database

Iv. Post-migration databases

This time is still relatively smooth, money and beauty, one is not less.

EF6 using Codefirst Total review in the original database (Iv. new entity object)

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.