Using structuremap for my DI. By default everything works, however I want to add fn and ln to AspNetUser DB. I've added a new class like so:
public class ApplicationUser : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
modified Startup.cs:
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<AppDbContext>()
.AddDefaultTokenProviders();
Modified ApplicationDbContext:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
}
Controller (modified to AppliationUser from Identityuser):
public AccountController(
SignInManager<ApplicationUser> signInManager,
UserManager<ApplicationUser> userManager)
{
m_signInManager = signInManager;
m_userManager = userManager;
}
Error i'm getting:
StructureMapConfigurationException: No default Instance is registered and cannot be automatically determined for type 'IUserStore'
There is no configuration specified for IUserStore
Thanks to @Jorge Rojas I was able to solve it. Not all references were replaced with ApplicationUser. In my Container I did not have to make any changes.
To Striter:
Is easy to miss an update to identity classes when creating subclases.
So, the idea is:
1) Check base clases you will override from identity: ApplicationUser, ApplicationRole, (if you modify it, not very common), ApplicationUserLogin, ApplicationClaims… etc. Note my example is taken from code I have where I modified UserRoles to include a company, so it's a bit more complex on the declaration.
For example, you may have:
Or (Not tested)
Then replace them accord in all subroutines. In case of ShaneKm, he probably left that unchanged on DbContext or UserStore:
And fixed it like:
Fo search of missing replacements, right-click on "IdentityUser" in public class ApplicationUser : IdentityUser
2) Sometimes you compile and not all things are updated, so old objs still refers to already changed code. Happens to me frequently with WCF. You have to clean obj and bin directories (I delete them) to ensure everything gets recompiled.
Hope this clarifies.