ASP.NET Web Application and MySQL with custom Identity Storage entity-framework-6 mysql


I want to implement a new WebApp in an existing MySQL database, the problem appears when I try to do the migration or the connection because I have already an 'Users' table in there, so I want to create my own tables (webapp_users, webapp_roles, ...).

I tried several ways to do it but no one worked, Can you help me and tell me the steps to follow to do this from the 'New > Project...' step?

Should I install the MySQL packages from the NuGet Package Manager, use external tools/addons, ...?

I will appreciate that, I'm completely blocked.

12/19/2016 8:04:42 AM

Accepted Answer

Create a db in your MySql server with the required tables and follow these steps :

  1. Import MySql.Web, MySql.Data and MySql.Data.Entity.EF6 dlls into your project first.
  2. Now create a Entity framework data model from your database by right clicking any folder -> new item -> Data -> entity data model
  3. Click Generate from database -> Next
  4. Click on New Connection -> Change ->
  5. Select MySql Database as datasource
  6. Give your MySql server credentials and select database to generate the data model from database

It should work fine.

Edit : You can also pass the name of the connection string (stored in the web.config) in your context to the base constructor of the IdentityDbContext

public class MyDbContext : IdentityDbContext<MyUser>
  public MyDbContext()
    : base("TheNameOfTheConnectionString")


Check this for more info

12/19/2016 11:21:52 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow