0

我正在开发 VS2015 预览版,但我被困在登录的某个地方。就像在 ASP.NET MVC VS2013 中,我们可以通过 SimpleMembershipInializer 登录,例如

public SimpleMembershipInitializer()
{
    Database.SetInitializer<LoginEntities>(null);

    try
    {
        using (var context = new LoginEntities())
        {
            if (!context.Database.Exists())
            {
                // Create the SimpleMembership database without Entity Framework migration schema
                ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
            }
        }

        WebSecurity.InitializeDatabaseConnection("LoginEntities", "UserProfile", "UserId", "UserName", autoCreateTables: true);
    }
    catch (Exception ex)
    {
        throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
    }

所以我在VS2015中像

 public class EBuilderUesr : IdentityUser<string, AspNetUserLogin, AspNetUserRole,AspNetUserClaim>
{
    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<EBuilderUesr> 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 AspNetUserRole : IdentityUserRole<string> { }
public class AspNetRole : IdentityRole<string, AspNetUserRole> { }
public class AspNetUserClaim : IdentityUserClaim<string> { }
public class AspNetUserLogin : IdentityUserLogin<string> { }
public class AspNetUser : IdentityUserLogin<string> { }

public class ApplicationDbContext : IdentityDbContext<EBuilderUesr, AspNetRole, string,AspNetUserLogin,AspNetUserRole,AspNetUserClaim>
{
    public ApplicationDbContext()
        : base("BuilderTrackerEntities")
    {
    }

    public static ApplicationDbContext Create()
    {
        return new ApplicationDbContext();
    }
}

现在进入 IdentityConfig.cs 是

public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context) 
        {
            //var manager = new ApplicationUserManager(new UserStore<EBuilderUesr>(context.Get<ApplicationDbContext>()));
            var manager = new ApplicationUserManager(new UserStore<EBuilderUesr, AspNetRole, string, AspNetUserLogin, AspNetUserRole, AspNetUserClaim>(context.Get<ApplicationDbContext>()));
}

在上面的 ApplicationUserManager 上出现错误..?

我也更改了配置文件中的连接字符串,但仍然出现错误,例如..

错误

请告诉我。我会做错什么..?

谢谢你,_jitendra

4

0 回答 0