Closed eld1887 closed 6 years ago
Can you upload on github the full code?
Sorry for the late answer. Here is the code. https://github.com/eld1887/identity
Update: ironically i get the error from above, but the user was inserted into the database...but it seems that´s a problem with login. (i disabled the ssl mode for my database(to find in the connection string))
pic from below shows the errors after i tried to login: http://abload.de/image.php?img=loginerrorsxplke.jpg
I don´t know if the code is wrong or something is wrong with my database. Thanks for your help
Probably is something with your database. I had tried here with the same custom fields you added on entities and the script is:
CREATE TABLE `identitylogin` (
`LoginProvider` VARCHAR(128) NOT NULL,
`ProviderKey` VARCHAR(128) NOT NULL,
`UserId` INT NOT NULL,
`Name` VARCHAR(256) NOT NULL,
PRIMARY KEY (`ProviderKey`, `UserId`, `LoginProvider`));
CREATE TABLE `identityrole` (
`Id` INT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(50) NOT NULL,
`IsDummy` BIT(1) NOT NULL,
PRIMARY KEY (`Id`));
CREATE TABLE `identityuser` (
`Id` INT NOT NULL AUTO_INCREMENT,
`Username` VARCHAR(256) NOT NULL,
`Email` VARCHAR(256) NULL,
`FirstName` VARCHAR(256) NULL,
`EmailConfirmed` BIT(1) NOT NULL,
`PasswordHash` LONGTEXT NULL,
`SecurityStamp` VARCHAR(38) NULL,
`PhoneNumber` VARCHAR(50) NULL,
`PhoneNumberConfirmed` BIT(1) NOT NULL,
`TwoFactorEnabled` BIT(1) NOT NULL,
`LockoutEnd` DATETIME NULL,
`LockoutEnabled` BIT(1) NOT NULL,
`AccessFailedCount` INT NOT NULL,
PRIMARY KEY (`Id`));
CREATE TABLE `identityuserclaim` (
`Id` INT NOT NULL AUTO_INCREMENT,
`UserId` INT NOT NULL,
`ClaimType` VARCHAR(256) NOT NULL,
`ClaimValue` VARCHAR(256) NULL,
PRIMARY KEY (`Id`));
CREATE TABLE `identityuserrole` (
`UserId` INT NOT NULL,
`RoleId` INT NOT NULL,
PRIMARY KEY (`UserId`, `RoleId`),
INDEX `FK_IdentityUserRole_IdentityRole_idx` (`RoleId` ASC),
CONSTRAINT `FK_IdentityUserRole_IdentityRole`
FOREIGN KEY (`RoleId`)
REFERENCES `identityrole` (`Id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `FK_IdentityUserRole_IdentityUser`
FOREIGN KEY (`UserId`)
REFERENCES `identityuser` (`Id`)
ON DELETE CASCADE
ON UPDATE CASCADE);
ALTER TABLE `identitylogin`
ADD INDEX `FK_IdentityLogin_IdentityUser_idx` (`UserId` ASC);
ALTER TABLE `identitylogin`
ADD CONSTRAINT `FK_IdentityLogin_IdentityUser`
FOREIGN KEY (`UserId`)
REFERENCES `identityuser` (`Id`)
ON DELETE CASCADE
ON UPDATE CASCADE;
ALTER TABLE `identityuserclaim`
ADD INDEX `FK_IdentityUserClaim_IdentityUser_idx` (`UserId` ASC);
ALTER TABLE `identityuserclaim`
ADD CONSTRAINT `FK_IdentityUserClaim_IdentityUser`
FOREIGN KEY (`UserId`)
REFERENCES `identityuser` (`Id`)
ON DELETE CASCADE
ON UPDATE CASCADE;
Thank you, with the new sql script it works fine. I don´t know where exactly the mistake was, but it runs :D
btw i started a new project and when i try to launch it, i get follwing error msg:
edit: solved the error by my own.
Thanks for your help and your hard work.
@eld1887 if you are using the CustomRole it has a property called IsDummy
, probably on your previous database it wasn't there.
hi, i try to run your example. I use mysql and i created the database identity and the tables with the given sql script. if i try to register a new user i get the follwing error msg:
An unhandled exception occurred while processing the request. NullReferenceException: Object reference not set to an instance of an object.
Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory+d__5.MoveNext()
NullReferenceException: Object reference not set to an instance of an object.