Migrating from default profile provider to SqlTableProfileProvider in ASP.net

Steps

  1. Prepare database. Create a table called aspnet_Profile2. It must have at least two columns:
    1. UserID (uniqueidentifier – Primary Key)
    2. LastUpdatedDate (datetime)
    3. The rest of the columns are your profile columns
  2. Modify Web.config (see sample below)
  3. Write a migration script (see sample below)
  4. 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