IdentityManager / IdentityManager.AspNetIdentity

ASP.NET Identity support for Thinktecture IdentityManager
Apache License 2.0
60 stars 51 forks source link

Change default conn string #17

Closed Trapulo closed 9 years ago

Trapulo commented 9 years ago

Hi, I'm using asp.net identity with a custom connection string name, but I cannot make identitymanager work using same conn string.

This is my config code: app.Map("/idm", Sub(idm)

                        Dim factory = New IdentityManager.Configuration.IdentityManagerServiceFactory()
                        factory.IdentityManagerService = New Registration(Of IIdentityManagerService)(Function(resolver)
                                                                                                          Dim userManager = New UserManager(Of Microsoft.AspNet.Identity.EntityFramework.IdentityUser)(New UserStore(Of Microsoft.AspNet.Identity.EntityFramework.IdentityUser))
                                                                                                          Dim roleManager = New RoleManager(Of IdentityRole)(New RoleStore(Of IdentityRole)())
                                                                                                          Return New AspNetIdentityManagerService(Of IdentityUser, String, IdentityRole, String)(userManager, roleManager)
                                                                                                      End Function)

                        Dim r As New IdentityManager.Configuration.LocalhostSecurityConfiguration
                        r.RequireSsl = False
                        idm.UseIdentityManager(New IdentityManagerOptions() With {.Factory = factory, .DisableUserInterface = False, .SecurityConfiguration = r})

                    End Sub
 )

and this is dbcontext used by my applicationusernanager, applicatiouserstore, applicationrolestore:

Public Class ApplicationDbContext Inherits IdentityDbContext(Of ApplicationUser) Public Sub New() MyBase.New("EntitiesDataContext", throwIfV1Schema:=False) End Sub

Public Shared Function Create() As ApplicationDbContext
    Return New ApplicationDbContext()
End Function

End Class

Still, identitymanager runs using DefaultConnection and not EntitiesDataContext connection string.

What's wrong? thanks

brockallen commented 9 years ago

I don't see where you configure the DbContext that's used by the RoleStore and UserStore. That's where you set the connection string (which I see you have via a default value in your ctor).