无法迁移IdentityModels.cs [macOS]

时间:2018-06-15 02:26:21

标签: asp.net macos authentication asp.net-identity ef-migrations

Visual Studio for Mac不会自动添加用于用户身份验证的代码。我创建了一个新的MVC Web应用程序,我从另一个在Windows上制作的项目中复制并粘贴了IdentityModel.cs文件。我把它添加到我的模型中。

然后我进入我的项目目录并运行命令: dotnet ef migrations添加InitialCreate

但我收到错误: 在程序集'Vidly'中找不到DbContext。确保您使用的是正确的程序集,并且该类型既不是抽象的也不是通用的

我想我必须在某处调用create()来修复它,但我不知道它应该去哪里。请帮帮我。

public class IdentityModels
    {
        // 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)
            {
                // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
                var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
                // Add custom user claims here
                return userIdentity;
            }
        }

        public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
        {
            public ApplicationDbContext()
                : base("DefaultConnection",throwIfV1Schema: false)
            {
            }

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

0 个答案:

没有答案