AspNetCore 中的 CreatePerOwinContext
替代品是什么(如果有)?
我正在尝试将 Asp.Net Identity 示例迁移到 AspNet Core,并发现遗留问题?提供CreatePerOwinContext
扩展方法的包与Asp.Net Core框架不兼容。
最佳答案
经过一番挖掘...似乎 CreatePerOwinContext
主要是依赖注入(inject)机制的一部分。
Microsoft.AspNetCore 1.0.0 作为一等公民支持依赖注入(inject)。
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);
}
}
关于asp.net-core - AspNetCore 中的 CreatePerOwinContext 替换是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38810310/