ASP.NET 身份与云服务器上的数据库
ASP.NET Identity with db on cloud server
我用 Identity 创建了一个新的 MVC5 项目,它创建了自己的数据库,我想用我的数据库和云服务器上的数据库进行更改。所以我有 2 个连接 stings,我唯一改变的是 table names ex: aspnetUser to CJUser 等等。我想要一些将自动生成的本地数据库更改为我自己的云数据库的简单方法。
我有 2 个连接字符串
Identity 创建的默认值和
我自己连接的数据库。
所以项目使用它自己的连接工作,但是当我将身份模型中的连接更改为我的连接时,它停止工作。
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("IdentityDbContext", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
}
我用 Identity 创建了一个新的 MVC5 项目,它创建了自己的数据库,我想用我的数据库和云服务器上的数据库进行更改。所以我有 2 个连接 stings,我唯一改变的是 table names ex: aspnetUser to CJUser 等等。我想要一些将自动生成的本地数据库更改为我自己的云数据库的简单方法。
我有 2 个连接字符串 Identity 创建的默认值和 我自己连接的数据库。
所以项目使用它自己的连接工作,但是当我将身份模型中的连接更改为我的连接时,它停止工作。
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("IdentityDbContext", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
}