因此,基本上在最终学习了如何将OpenAuth更改为不使用.NET 4.5中的DefaultConnection之后,我继续进行4.5.1的讨论,使这些学习无济于事。AuthConfig.cs的职责现在位于Startup.Auth.cs中,OpenAuth的静态方法已被抽象化,因此,我无法再直接更改OpenAuth.ConnectionString的默认值。
在.NET 4.5.1中更改成员资格的连接字符串/数据库的最佳实践是什么?
与Microsoft.AspNet.Identity.EntityFramework 1.0.0-rc1一起使用
在AccountController的无参数构造函数中,更改该行
IdentityManager = new AuthenticationIdentityManager(new IdentityStore());
至
IdentityManager = new AuthenticationIdentityManager(new IdentityStore(new DefaultIdentityDbContext("YourNameOrConnectionString")));
而且你很好。
与Microsoft.AspNet.Identity.EntityFramework 1.0.0一起使用
与我们为发布候选版本所做的类似,但我们在不同的地方进行。打开IdentityModels.cs
作为VS模板的一部分创建的对象,然后将以下构造函数添加到ApplicationDbContext
该类中:
public ApplicationDbContext(string nameOrConnectionString)
: base(nameOrConnectionString)
{
}
您现在可以更改参数的构造函数AccountController
从
public AccountController()
: this(new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext())))
{
}
至
public AccountController()
: this(new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext("YourNameOrConnectionString"))))
{
}
和你完成。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句