0
我发现下面的教程如何形成asp.net迁移到asp.net核心运行在Linux上的项目: https://docs.microsoft.com/en-us/aspnet/core/migration/mvc迁移从asp.net到asp.net核心
不幸的是,当我试图“配置身份和会员资格” ,我将代码复制到项目看起来像有没有对.NET核心
例如,这部分这样的命令:
然后,打开Startup.cs和更新ConfigureServices()方法使用 实体框架和身份服务:
public void ConfigureServices(IServiceCollection services)
{
// Add EF services to the services container.
services.AddEntityFramework(Configuration)
.AddSqlServer()
.AddDbContext<ApplicationDbContext>();
// Add Identity services to the services container.
services.AddIdentity<ApplicationUser, IdentityRole>(Configuration)
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddMvc();
}
同样的情况是ApplicationUser.cs
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
namespace NewMvc6Project.Models
{
public class ApplicationUser : IdentityUser
{
}
}
和ApplicationDbContext.cs
using Microsoft.AspNetCore.Identity.EntityFramework;
using Microsoft.Data.Entity;
namespace NewMvc6Project.Models
{
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
{
Database.EnsureCreated();
}
protected override void OnConfiguring(DbContextOptions options)
{
options.UseSqlServer();
}
}
}
它是错的教程或我应该安装一些新的软件包?
,你说有没有ConfigureService方法在启动?你的问题是什么? –
否否。我有ConfigureService方法,但现在我不知道在这种情况下该怎么办: http://scr.hu/2aps/nrpyr http://scr.hu/2aps/g514u http:// scr。 hu/2aps/ozpay http://scr.hu/2aps/29zjc – Halas
'Application.UseSqlServer();'和'OnConfiguring'不需要在'ApplicationDbContext'中, 删除那些,尝试构建并重新启动visual studio to看看错误是否消失。 – NucS