We're looking to extend the user model (ApplicationUser) with an extra field. Following the CMS docs here (https://world.optimizely.com/documentation/developer-guides/CMS/security/episerver-aspnetidentity/), we have this setup:
public class CustomUser : ApplicationUser { public string CustomData { get; set; } }
// In Startup.cs:
services.AddCmsAspNetIdentity<CustomUser>();
With this, however, during application start, we encounter the error "SqlException, invalid column name 'CustomData'". Upon investigation, this is because in the database, the table dbo.AspNetUsers does not have the column CustomData created.
Going through the internet researching this, it seems like there is consensus that the documentation failed to detail the migration step: updating the database to reflect this new change:
- From pre-CMS 12: https://www.wearediagram.com/blog/setting-up-migrations-for-episerver-aspnetidentity
- Still existing in CMS 12: https://www.getadigital.com/no/blog/upgrading-to-optimizely-12-asp.net-core-identity
With this in mind, when we go into the database and manually add the column to the AspNetUsers table, the error goes away as expected. But Optimizely obviously does not recommend interfering with the database schema, and our implementation will eventually be hosted on DXP.
We have opened a support ticket (#893747), and Optimizely is currently processing it, but we wanted to try and see if others on the forums have solved this issue before, and what's the best practice recommendation to solving this issue.