Migrating from default profile provider to SqlTableProfileProvider in ASP.net
Steps
- Prepare database. Create a table called aspnet_Profile2. It must have at least two columns:
- UserID (uniqueidentifier – Primary Key)
- LastUpdatedDate (datetime)
- The rest of the columns are your profile columns
- Modify Web.config (see sample below)
- Write a migration script (see sample below)
- Modify Web.config one more time, renaming JobTitle2 to JobTitle, and delete the default provider
Web.config
Migration script
Dim pc As ProfileInfoCollection = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All)
For Each pi As ProfileInfo In pc
Dim prof As Object = ProfileBase.Create(pi.UserName)
prof.FriendlyName2 = prof.FriendlyName
prof.JobTitle2 = prof.JobTitle
prof.Phone2 = prof.Phone
Next
Web.config
About this entry
You’re currently reading “ Migrating from default profile provider to SqlTableProfileProvider in ASP.net ,” an entry on Chui's Counterpoint
- Published:
- 9.6.11 / 8am
- Category:
- .Net, Engineering notes
Comments are closed
Comments are currently closed on this entry.