Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 无法迁移IdentityModels.cs[macOS]_Asp.net_Macos_Authentication_Asp.net Identity_Entity Framework Migrations - Fatal编程技术网

Asp.net 无法迁移IdentityModels.cs[macOS]

Asp.net 无法迁移IdentityModels.cs[macOS],asp.net,macos,authentication,asp.net-identity,entity-framework-migrations,Asp.net,Macos,Authentication,Asp.net Identity,Entity Framework Migrations,Visual Studio for Mac不会自动添加用于用户身份验证的代码。我创建了一个新的MVC web应用程序,复制并粘贴了另一个项目中的IdentityModel.cs文件,该项目是有人在Windows上创建的。我把它添加到我的模型中 然后,我将cd光盘刻录到我的项目目录中,并运行以下命令: dotnet ef迁移添加初始创建 但我得到了一个错误: 在程序集“Vidly”中未找到DbContext。确保使用的程序集正确,并且类型既不是抽象的也不是泛型的 我想我必须在某个地方调用creat

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

然后,我将cd光盘刻录到我的项目目录中,并运行以下命令: dotnet ef迁移添加初始创建

但我得到了一个错误: 在程序集“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();
            }
        }
    }
公共类标识模型
{
//您可以通过向ApplicationUser类添加更多属性来为用户添加配置文件数据,请访问http://go.microsoft.com/fwlink/?LinkID=317594 了解更多。
公共类应用程序用户:IdentityUser
{
公共异步任务GenerateUserIdentityAsync(用户管理器)
{
//注意authenticationType必须与CookieAuthenticationOptions.authenticationType中定义的类型匹配
var userIdentity=wait manager.CreateIdentityAsync(这是DefaultAuthenticationTypes.ApplicationOkie);
//在此处添加自定义用户声明
返回用户身份;
}
}
公共类ApplicationDbContext:IdentityDbContext
{
公共应用程序上下文()
:base(“DefaultConnection”,throwifvv1schema:false)
{
}
公共静态应用程序上下文创建()
{
返回新的ApplicationDbContext();
}
}
}

尝试运行
dotnet ef迁移添加InitialCreate-s-p
。您必须告诉命令哪个是您的启动项目,以及您要为哪个项目添加迁移。项目的名称是testmvc。我做了:dotnet ef迁移添加初始值create-s testmvc-p testmvc我得到:找不到匹配命令“dotnet ef”的可执行文件您使用的是多个项目吗?不只是testmvc项目您有哪个ef核心版本?