Security.Identity icon indicating copy to clipboard operation
Security.Identity copied to clipboard

Add migration error using AddCustomIdentity

Open pavini opened this issue 4 years ago • 3 comments

I'm trying to use AddCustomIdentity<ApplicationUser>() and I'm getting this error when run the add migration command.

No DbContext named 'NetDevPackAppDbContext' was found. File IdentityConfig.cs

services.AddIdentityEntityFrameworkContextConfiguration(options =>
                options.UseSqlServer(configuration.GetConnectionString("DefaultConnection"),
                    b => b.MigrationsAssembly("Equinox.Infra.CrossCutting.Identity")))
                .AddCustomIdentity<ApplicationUser>();

ApplicationUser.cs

public class ApplicationUser : IdentityUser
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }

pavini avatar Apr 15 '21 02:04 pavini

Isso é uso errado da ferramenta ou algo que precisa ser ajustado?

pavini avatar Apr 22 '21 13:04 pavini

i am getting this error for AddCustomIdentityAndKeyConfiguration. i have an idea about the reason : the user role context and configuratyion classes are both in one file. i look for that stacoverflow answer

biproberkay avatar Jan 23 '22 12:01 biproberkay

hey @pavini I suppoose found the solution.

  • first: dotnet ef dbcontext list you will see 👇

AspNetCore.Jwt.Sample.Config.MyIntIdentityContext AspNetCore.Jwt.Sample.Config.MyIdentityContext

  • theese two copy your context
  • dotnet ef migrations add Initial -c AspNetCore.Jwt.Sample.Config.MyIntIdentityContext use like this.
  • and that is ok it works.

biproberkay avatar Jan 23 '22 12:01 biproberkay