5. ABPZero series Tutorials: how to modify the User table structure with multiple seller tools, abpzerouser

Source: Internet
Author: User

5. ABPZero series Tutorials: how to modify the User table structure with multiple seller tools, abpzerouser

After all, this framework is developed by foreigners. It is not suitable for Chinese people in some places. For example, we need to enter the first name and last name during registration. What we want to talk about today is how to remove these two fields.

First, see the following modified

 

User table structure modification

Modify the User class and add the following code:

File Path: D: \ abp version \ aspnet-zero-3.4.0 \ aspnet-zero-3.4.0 \ src \ MyCompanyName. AbpZeroTemplate. Core \ Authorization \ Users \ User. cs

//Can add application specific user properties here        private new string Name { get; set; }        private new string Surname { get; set; }        [Required(AllowEmptyStrings = true)]        public override string EmailAddress { get; set; }

 

Modify the AbpZeroTemplateDbContext. cs class and add the OnModelCreating method. The Code is as follows:

File Path: D: \ abp version \ aspnet-zero-3.4.0 \ aspnet-zero-3.4.0 \ src \ MyCompanyName. AbpZeroTemplate. EntityFramework \ AbpZeroTemplateDbContext. cs

protected override void OnModelCreating(DbModelBuilder modelBuilder)        {            base.OnModelCreating(modelBuilder);            modelBuilder.Entity<User>().Ignore(a => a.Name);            modelBuilder.Entity<User>().Ignore(a => a.Surname);            modelBuilder.Entity<User>().Property(a => a.EmailAddress).IsOptional();        }

 

Override method 'onmodelcreating', and set Name and SurName to ignore.
Then, set EmailAddress to void.

 

Execute migration

Open the VS package management console, and select the. EntityFramework project in the package management console as the default project. Then, run the following command on the console:

Add-Migration "Renamed_NameAndSurnameAndEmailAddress_To_User"

 

After successful execution, run the following command:

Update-Database

 

At this time, the structure of the User table has been changed, and the Name, Surname, and EmailAddress (which has been changed to void) have been removed)

 

Now, the structure of the User table has been modified.

 

Total returned directory

 

Related Article

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.