none
Adapting Identity framework database into another custom database. Database first (Hash Issue)

    Pertanyaan

  • 0 down vote favorite

    I'm trying to Implement Microsoft's Identity Framework (IF) into my Web site. I designed the database in such a way the framework would recognize the structure and work around it. But when I register an email all though it does receive the data properly, the IF hasher doesn't work. There's an error implying that the ApplicationUser is not on the context, but the controller recieves data, on debug I can see the email and password. but on this line

    var result = await UserManager.CreateAsync(user, model.Password);

    Seems to be looking for a value in my model that it's not there.

    Thus I believe the issue is on the table AspNetUsers, is there a hidden property I missed?

    CREATE TABLE [dbo].[AspNetUsers] (
    [Id]                   NVARCHAR (128) NOT NULL,
    [Email]                NVARCHAR (256) NULL,
    [EmailConfirmed]       BIT            NOT NULL,
    [PasswordHash]         NVARCHAR (MAX) NULL,
    [Password] [nvarchar](500) NULL,
    [SecurityStamp]        NVARCHAR (MAX) NULL,
    [PhoneNumber]          NVARCHAR (MAX) NULL,
    [PhoneNumberConfirmed] BIT            NOT NULL,
    [TwoFactorEnabled]     BIT            NOT NULL,
    [LockoutEndDateUtc]    DATETIME       NULL,
    [LockoutEnabled]       BIT            NOT NULL,
    [AccessFailedCount]    INT            NOT NULL,
    [UserName]             NVARCHAR (256) NOT NULL,
    [Login] [nvarchar](50) NOT NULL,
    [CreationDate] [datetime] NULL,
    [ApprovalDate] [datetime] NULL,
    [LastLoginDate] [datetime] NULL,
    [IsLocked] [bit] NOT NULL,
    [PasswordQuestion] [nvarchar](max) NULL,
    [PasswordAnswer] [nvarchar](max) NULL,
    [ActivationToken] [nvarchar](200) NULL,
    
    CONSTRAINT [PK_dbo.AspNetUsers] PRIMARY KEY CLUSTERED ([Id] ASC),
         CONSTRAINT [UX_User_EMail] UNIQUE NONCLUSTERED 
    (
        [EMail] ASC
    ),
     CONSTRAINT [UX_User_Login] UNIQUE NONCLUSTERED 
    (
        [Login] ASC
    )
    );
    
    ALTER TABLE [dbo].[AspNetUsers] ADD  CONSTRAINT [DF_User_IsLocked]  DEFAULT ((0)) FOR [IsLocked]
    GO
    ALTER TABLE [dbo].[AspNetUsers] ADD  CONSTRAINT [DF_User_EmailConfirmed]  DEFAULT ((0)) FOR [EmailConfirmed]
    GO
    ALTER TABLE [dbo].[AspNetUsers] ADD  CONSTRAINT [DF_User_PhoneNumberConfirmed]  DEFAULT ((0)) FOR [PhoneNumberConfirmed]
    GO
    ALTER TABLE [dbo].[AspNetUsers] ADD  CONSTRAINT [DF_User_TwoFactorEnabled]  DEFAULT ((0)) FOR [TwoFactorEnabled]
    GO
    ALTER TABLE [dbo].[AspNetUsers] ADD  CONSTRAINT [DF_User_LockoutEnabled]  DEFAULT ((0)) FOR [LockoutEnabled]
    GO
    ALTER TABLE [dbo].[AspNetUsers] ADD  CONSTRAINT [DF_User_AccessFailCount]  DEFAULT ((0)) FOR [AccessFailedCount]
    GO
    
    GO
    CREATE UNIQUE NONCLUSTERED INDEX [UserNameIndex]
        ON [dbo].[AspNetUsers]([UserName] ASC);

    I've seen similar questions and there's a hint that there's a property called "Discriminator" but it's not described what it is and how should I declare it. Thanks!

    Sabtu, 29 September 2018 04.37

Semua Balasan

  • I've seen similar questions and there's a hint that there's a property called "Discriminator" but it's not described what it is and how should I declare it. 

    https://www.codeproject.com/Tips/677279/SQL-script-for-creating-an-ASP-NET-Identity-Databa

    Sabtu, 29 September 2018 14.21
  • Hi Khamul777,

    This forum discusses and asks questions related to the current versions of the ADO.NET Entity Framework, since your issue is more related to asp.net identity, I would suggest that you could post your issue on asp.net forum for suitable support.

    https://forums.asp.net/25.aspx/1?Security

    Thanks for your understanding and cooperation.

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Senin, 01 Oktober 2018 02.02