Hi, I have set up my forms and database to the new Identity system. Databse migrations all in place and model set up to allow use of additional profile items.
Have then managed to tie this in to the facebook login and retrieve databack from Facebook for the currently logged in user. However, I cannot seem to actually persist this profile data to the database.
The routine I am using is below, this all works perfectly, the usermanager adds the new claim to the database fine, the facebook client gets all the extra info and adds it to the currentUser as expected, but this additional data is never actually saved. The only method I can find that looks like it should perform this function is UserManager.Update
Using this actually reports success but on check the DB the additional info isn't saved.
Does anybody know how to trigger saving of this extra profile into to the user? (I also tried IdentityDbContext.SaveChanges but this does nothing either)
Thanks
Private Async Function StoreFacebookAuthToken(currentUser As ApplicationUser) As Threading.Tasks.Task Dim authenticationManager As IAuthenticationManager = Context.GetOwinContext().Authentication Dim claimsIdentity = Await authenticationManager.GetExternalIdentityAsync(DefaultAuthenticationTypes.ExternalCookie) If Not claimsIdentity Is Nothing Then 'retrieve the existing claims for the user and add the FacebookAccessTokenClaim Dim UserManager = New UserManager() Dim currentClaims = UserManager.GetClaims(currentUser.Id) Dim facebookAccessToken = claimsIdentity.FindAll("FacebookAccessToken").First() If currentClaims.Count <= 0 Then UserManager.AddClaim(currentUser.Id, facebookAccessToken) Dim fb As New Facebook.FacebookClient(facebookAccessToken.Value) currentUser.email = fb.Get("/me").email currentUser.name_first = fb.Get("/me").first_name currentUser.name_last = fb.Get("/me").last_name currentUser.name = fb.Get("/me").name currentUser.gender = fb.Get("/me").gender currentUser.home_town = fb.Get("/me").hometown.name currentUser.locale = fb.Get("/me").locale Dim result = UserManager.Update(currentUser) 'Dim result2 = Microsoft.AspNet.Identity.UserManagerExtensions.Update(UserManager, currentUser) 'Dim v As New Microsoft.AspNet.Identity.EntityFramework.IdentityDbContext 'v.SaveChanges() End If End If End Function