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