问题描述
所以基本上后,终于学会,我已经转移到4.5.1,呈现这些学习收获没有实际意义。 AuthConfig.cs的职责,现在居住在Startup.Auth.cs,OpenAuth的静态方法已被抽象化了,所以我不能再更改OpenAuth.ConnectionString的默认值直接。
So basically after finally learning how to change OpenAuth to not use DefaultConnection in .NET 4.5, I've moved on to 4.5.1, rendering those learnings moot. The duties of AuthConfig.cs now reside in Startup.Auth.cs, The static methods of OpenAuth have been abstracted away and therefore I can no longer change the default value of OpenAuth.ConnectionString directly.
什么是.NET中的4.5.1改变会员的连接字符串/数据库中的最佳实践?
What is the best practice for changing Membership's connection string/database in .NET 4.5.1?
推荐答案
工程与Microsoft.AspNet.Identity.EntityFramework 1.0.0-RC1
Release Candidate
Works with Microsoft.AspNet.Identity.EntityFramework 1.0.0-rc1
在无参数的构造函数的AccountController,更改行
In the parameterless constructor for AccountController, change the line
IdentityManager = new AuthenticationIdentityManager(new IdentityStore());
到
IdentityManager = new AuthenticationIdentityManager(new IdentityStore(new DefaultIdentityDbContext("YourNameOrConnectionString")));
和你去好。
搜索结果
and you're good to go.
工程与Microsoft.AspNet.Identity.EntityFramework 1.0.0
Works with Microsoft.AspNet.Identity.EntityFramework 1.0.0
要我们所做的候选发布版类似,但我们这样做在不同的地方。打开 IdentityModels.cs
被创建为VS模板的一部分,下面的构造添加到 ApplicationDbContext
类:
Similar to what we did for release candidate, but we do this in a different place. Open IdentityModels.cs
that was created as part of the VS template and add the following constructor to the ApplicationDbContext
class:
public ApplicationDbContext(string nameOrConnectionString)
: base(nameOrConnectionString)
{
}
和您现在可以从
public AccountController()
: this(new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext())))
{
}
到
public AccountController()
: this(new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext("YourNameOrConnectionString"))))
{
}
和你做。
这篇关于设置ASP.NET身份ConnectionString属性在.NET 4.5.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!