.net - Access to UserManager in Asp.Net Core 2.0 -


i reference usermanager of identity, because create test user seed data.

i context:

var context = new mycontext(serviceprovider.getrequiredservice<dbcontextoptions<apicontext>>()) 

but need reference usermanager because need use create user in static seeddata class.

i use asp.net core 2.0.

is possible it?

i pretty sure can use thru constructor injection.

add identity startup.cs

public class usersrepository {     public usersrepository(usermanager<users> usermanager)     {         _usermanager = usermanager;     }    public void foo(){      _usermanager.dosomething();     } } 

it works me fine.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -