Asp.net 无法迁移IdentityModels.cs[macOS]
Visual Studio for Mac不会自动添加用于用户身份验证的代码。我创建了一个新的MVC web应用程序,复制并粘贴了另一个项目中的IdentityModel.cs文件,该项目是有人在Windows上创建的。我把它添加到我的模型中 然后,我将cd光盘刻录到我的项目目录中,并运行以下命令: dotnet ef迁移添加初始创建 但我得到了一个错误: 在程序集“Vidly”中未找到DbContext。确保使用的程序集正确,并且类型既不是抽象的也不是泛型的 我想我必须在某个地方调用create()来修复它,但我不知道它应该放在哪里。请帮帮我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
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核心版本?