如果有的话,AspNetCore中的CreatePerOwinContext
替代方法是什么?
我正在尝试将Asp.Net Identity示例迁移到AspNet Core,并发现提供CreatePerOwinContext
扩展方法的旧版包与Asp.Net Core框架不兼容。
如果有的话,AspNetCore中的CreatePerOwinContext
替代方法是什么?
我正在尝试将Asp.Net Identity示例迁移到AspNet Core,并发现提供CreatePerOwinContext
扩展方法的旧版包与Asp.Net Core框架不兼容。
CreatePerOwinContext
主要是依赖注入机制的一部分。https://docs.asp.net/en/latest/fundamentals/dependency-injection.html
大多数常见的身份验证服务都提供了扩展功能。例如,下面是CreatePerOwinContext
与IServiceCollection
的比较:
IServiceCollection(AspNetCore 1.0.0)
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(config.GetConnectionString("DefaultConnection")));
}
}
CreatePerOwinContext(已过时)
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.CreatePerOwinContext(ApplicationDbContext.Create);
}
}