EF6 use of Codefirst in the original database review (iii, re-migration)

Source: Internet
Author: User

Originally learned time, quite smooth, did not expect to use again, or encountered a lot of problems, resulting in the failure of the update, so, can only reconstruct the migration, so as not to look at the chaos.

First, delete the migration, restore the data to the (a) End state

1. Delete Folder

2. Delete a table

3. Delete Columns

4. Comment out the newly added attributes

Second, re-operation EF6 in the original database using Codefirst Total review (second, new requirements, simple modification of the original table)

Among them, the blog entity was modified to

Iii. Results of operation

Isdelete default value and Isdelete = True in the blog entity constructor; Independent.

The new field is of type bool and the system is not allowed to be empty by default, so the default value is assigned to False (0)

Similarly, when a value type field is added, it should also be assigned a value of 0.

Iv. changing the constructor back to

There is no need to migrate because of database-independent.

V. Now the database table blogs has the Isdelete field, consistent with the entity object, and then run the previously generated interface

If the delete operation is not done, everything is fine.

Vi. Deleting a modified soft delete

Original code

Modified to:

Seven, re-run the system, add a new record

Tables in the database

Viii. Delete a newly created record

Tables in the database

Page Display list

EF6 use of Codefirst in the original database review (iii, re-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.