无法找到TEntity类型或命名空间

时间:2016-09-14 17:22:59

标签: asp.net-mvc

我希望有人能帮助我。 在官方文档中,它声明TEntity应该位于System.Data.Entity内,如下所示:https://msdn.microsoft.com/en-us/library/gg696460(v=vs.113).aspx

但是,即使使用using System.Data.Entity;,我仍然会获得The type or namespace TEntity could not be found。我在这里做错了吗?我觉得我犯了一个愚蠢的错误:(

using System.Data.Entity;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;

namespace Assignment1.Models
{
    // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
    public class ApplicationUser : IdentityUser
    {
        public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager, string authenticationType)
        {
            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
            var userIdentity = await manager.CreateIdentityAsync(this, authenticationType);
            // Add custom user claims here
            return userIdentity;
        }
    }

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        DbSet<TEntity> Smartphones { get; set; }

        public ApplicationDbContext()
            : base("DefaultConnection", throwIfV1Schema: false)
        {
        }

        public static ApplicationDbContext Create()
        {
            return new ApplicationDbContext();
        }
    }
}

编辑:我正在使用Entity Framework 6.0 +

0 个答案:

没有答案