简体   繁体   中英

The type namespace name IdentityUser could not be found

I keep getting this error for the last two frameworks that I have included. I have searched up and down. Can't figure what it is. I have installed the NuGet packages and tried to recompile multiple times. Nothing is working. Here is my code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IdentityUser;
using IdentityDbContext;

namespace UserProfileInfo.Models
{
    public class UserProfile : IdentityUser
    {
        public virtual UserProfile UserInfo { get; set; }
    }

    public class UserProfileDB
    {
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
    public class MyDbContext : IdentityDbContext<UserProfile>
    {
        public MyDbContext()
            : base("DefaultConnection")
        {

        }
        public System.Data.Entity.DbSet<UserProfile> UserInfo { get; set; }
    }
}

There is no needs for -

using IdentityUser;
using IdentityDbContext;

Instead you need to add following -

using Microsoft.AspNet.Identity.EntityFramework;

Make sure you have that DLL as a reference as shown below. If it is not available, then you can get that nuget from here .

在此输入图像描述

For AspNet Core 1 use NuGet:

Microsoft.AspNetCore.Identity.EntityFrameworkCore

For AspNet Core 2 use NuGet:

Microsoft.AspNetCore.Identity

这是针对Dotnet Core的,您不会收到任何警告

using Microsoft.Extensions.Identity.Stores

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM