0

I am learning asp.net identity. I found out this nuget package from this link. It is link of sample releases, though in alpha version and not meant for actual use, i was curious for learning perspective. So installed it and really liked it (from here). Now from in empty MVC project with ASP.NET identity, using this link, i can use MySql as a storage provider.Now the question is how do i use mysql with identity samples?

Community
  • 1
  • 1
Gaurav Chauhan
  • 1,295
  • 4
  • 17
  • 41
  • You need to have the identity tables created and the correct connectionstring in web.config. – Cristian Szpisjak Oct 21 '16 at 11:54
  • Actually identity in "empty" project is working fine. When i install identity samples (it is awesome...), it overwrites my changes and starts using localdb. – Gaurav Chauhan Oct 21 '16 at 12:02
  • Follow the instructions for installing the Mysql entity framework provider on the [Mysql website](https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html). – Luke Oct 21 '16 at 12:04

1 Answers1

1

You need to change the connection string. By default the identity model uses the default connection string that is on the web.config. If the database doesn't exist it will create it along with the tables. You need to add mysql to visual studio first you can find this on mysql page. then create a connection to mysql then specify this by replacing the DefaultConnection"

located on the IdentityModel.cs

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext()
            : base("DefaultConnection", throwIfV1Schema: false)
        {
        }

        public static ApplicationDbContext Create()
        {
            return new ApplicationDbContext();
        }
    }
npo
  • 1,060
  • 8
  • 9