«DbUpdateException: ошибка при обновлении записей» Ошибка после реализации пользовательского класса идентификации - PullRequest
0 голосов
/ 28 сентября 2019

Я пытаюсь создать форму регистрации пользователя на ядре .net, используя подход DbFirst.Я создал таблицу в базе данных.Создан основной проект .net с использованием аутентификации пользователя (встроенная идентификация).Тогда я сделал Леса.После заполнения полей правильными значениями и публикации запроса я получаю эту ошибку:

Произошло необработанное исключение при обработке запроса.

SqlException: Неверное имя столбца 'AccessFailedCount'.Неверное имя столбца 'ConcurrencyStamp'.Неверное имя столбца 'LockoutEnabled'.Неверное имя столбца 'LockoutEnd'.Неверное имя столбца «NormalizedEmail».Неверное имя столбца «NormalizedUserName».Неверное имя столбца PasswordHash.Неверное имя столбца 'PhoneNumber'.Неверное имя столбца 'PhoneNumberConfirmed'.Неверное имя столбца «SecurityStamp».Неверное имя столбца 'TwoFactorEnabled'.Неверное имя столбца 'UserName'.

DbUpdateException: при обновлении записей произошла ошибка.Подробности см. Во внутреннем исключении.

Поля, упомянутые выше, находятся в файле только для чтения, который называется IdentityUser (тот, от которого я наследую).Это только для чтения, поэтому я не могу удалить из него какие-либо поля.

Это мой регистр.ошибка но возможно я ошибаюсьUser.cs

public partial class User :IdentityUser<int>
    {
        public int Id { get; set; }
        public string Country { get; set; }
        public string PersonalId { get; set; }
        public string MobilePhone { get; set; }
        public string Email { get; set; }
        public DateTime BirthDate { get; set; }
        public string Password { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
        public byte[] Idimage { get; set; }
        public bool? EmailConfirmed { get; set; }
        public bool? Smsconfirmed { get; set; }
    }

IdentityUser

namespace Microsoft.AspNetCore.Identity
{
    //
    // Summary:
    //     Represents a user in the identity system
    //
    // Type parameters:
    //   TKey:
    //     The type used for the primary key for the user.
    public class IdentityUser<TKey> where TKey : IEquatable<TKey>
    {
        //
        // Summary:
        //     Initializes a new instance of Microsoft.AspNetCore.Identity.IdentityUser`1.
        public IdentityUser();
        //
        // Summary:
        //     Initializes a new instance of Microsoft.AspNetCore.Identity.IdentityUser`1.
        //
        // Parameters:
        //   userName:
        //     The user name.
        public IdentityUser(string userName);

        //
        // Summary:
        //     Gets or sets the date and time, in UTC, when any user lockout ends.
        //
        // Remarks:
        //     A value in the past means the user is not locked out.
        public virtual DateTimeOffset? LockoutEnd { get; set; }
        //
        // Summary:
        //     Gets or sets a flag indicating if two factor authentication is enabled for this
        //     user.
        [PersonalData]
        public virtual bool TwoFactorEnabled { get; set; }
        //
        // Summary:
        //     Gets or sets a flag indicating if a user has confirmed their telephone address.
        [PersonalData]
        public virtual bool PhoneNumberConfirmed { get; set; }
        //
        // Summary:
        //     Gets or sets a telephone number for the user.
        [ProtectedPersonalData]
        public virtual string PhoneNumber { get; set; }
        //
        // Summary:
        //     A random value that must change whenever a user is persisted to the store
        public virtual string ConcurrencyStamp { get; set; }
        //
        // Summary:
        //     A random value that must change whenever a users credentials change (password
        //     changed, login removed)
        public virtual string SecurityStamp { get; set; }
        //
        // Summary:
        //     Gets or sets a salted and hashed representation of the password for this user.
        public virtual string PasswordHash { get; set; }
        //
        // Summary:
        //     Gets or sets a flag indicating if a user has confirmed their email address.
        [PersonalData]
        public virtual bool EmailConfirmed { get; set; }
        //
        // Summary:
        //     Gets or sets the normalized email address for this user.
        public virtual string NormalizedEmail { get; set; }
        //
        // Summary:
        //     Gets or sets the email address for this user.
        [ProtectedPersonalData]
        public virtual string Email { get; set; }
        //
        // Summary:
        //     Gets or sets the normalized user name for this user.
        public virtual string NormalizedUserName { get; set; }
        //
        // Summary:
        //     Gets or sets the user name for this user.
        [ProtectedPersonalData]
        public virtual string UserName { get; set; }
        //
        // Summary:
        //     Gets or sets the primary key for this user.
        [PersonalData]
        public virtual TKey Id { get; set; }
        //
        // Summary:
        //     Gets or sets a flag indicating if the user could be locked out.
        public virtual bool LockoutEnabled { get; set; }
        //
        // Summary:
        //     Gets or sets the number of failed login attempts for the current user.
        public virtual int AccessFailedCount { get; set; }

        //
        // Summary:
        //     Returns the username for this user.
        public override string ToString();
    }
}

ОБНОВЛЕНИЕ: только что обнаружил, что я не вижу Таблицы идентификации в моей базе данных.Думаю, это еще одна проблема.

...