1

I created a new MVC5 project with Identity and it makes its own db which i want to change with same one but mine and on cloud server. so i have 2 connection stings and the only things that i changed was table names ex: aspnetUser to CJUser and so on. I want some simple way of changing auto generated local db to my own cloud one.

2 connection strings i have are default one which Identity creates and my own db which i connected.

So project works with its own connection but when i change connections in Identity models to mine, it stops working.

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();
    }
}

}

Nikita Chernykh
  • 270
  • 1
  • 4
  • 18
  • Of course it does. It is expecting a specific table name, and you are using a different table name. If you want to use custom names, see http://stackoverflow.com/questions/22855428/how-to-change-table-names-for-asp-net-identity-2-0-with-int-id-columns. However, you really need to be using the same table names both locally and in your cloud database. – Brendan Green May 04 '15 at 00:59
  • 1
    When you say "it stops working", can you be more specific? What error are you getting? – Rajeev Goel May 04 '15 at 02:58

1 Answers1

1

Try to use Automatic migration

Lis
  • 429
  • 4
  • 10