Ich versuche, die ASP.NET Identität anpassen integer basierte Schlüssel anstelle von String zu verwenden. Der Code wird kompiliert, aber wenn ich die App ausführe, wird ein Fehler für die Verletzung der Typbeschränkung ausgegeben. Hier ist, wie meine Identität Klassen aussehen:ASPnet Identität MVC6 Verletzen die Typeinschränkung
public class AppUser: IdentityUser<int, AppUserClaim, AppUserRole, AppUserLogin>
{
public DateTime FirstTrip { get; set; }
}
public class AppRole : IdentityRole<int, AppUserRole, AppRoleClaim>
{
}
public class AppUserClaim : IdentityUserClaim<int>
{
}
public class AppRoleClaim : IdentityRoleClaim<int>
{
}
public class AppUserLogin : IdentityUserLogin<int>
{
}
public class AppUserRole : IdentityUserRole<int>
{
}
public class AppUserToken : IdentityUserToken<int>
{
}
Meine AppDbContext Klasse:
public class AppDbContext: IdentityDbContext<AppUser,AppRole, int, AppUserClaim, AppUserRole, AppUserLogin, AppRoleClaim, AppUserToken>
{
//other code
}
Und hier ist, wie ich bin Einrichtung Identität in meiner startup.cs Klasse:
services.AddIdentity<AppUser, AppRole>(config => //register ASPNET Identity
{
config.User.RequireUniqueEmail = true;
config.Password.RequiredLength = 8;
config.Cookies.ApplicationCookie.LoginPath = "/Auth/Login";
})
.AddEntityFrameworkStores<AppDbContext, int>();
Wenn ich laufen die App bekomme ich folgenden Fehler:
Dieser setu p steht im Einklang mit einigen Vorschlägen wie:
Why does this violate the type constraint?
ASP.NET identity configuration exception and that breaks dotnet.exe run process
Was bin ich?