Change the context class and user manager to use the key type
In IdentityModels.cs, change the definition of the ApplicationDbContext class to use your new customized classes and an int for the key, as shown in the highlighted code.
I think the two is not a similar class in this two articles. In the second article, the MySQLDatabase is just a Helper class, you could find out a passage explains that the “MySQLDatabase” contains the MySQL database connection and methods for performing
database operations. UserStore and RoleStore are both instantiated with an instance of this class in the “Data access layer classes” section. About the specific code, you could refer to the following link.
For the first ApplicationDbContext which is integrated from IdentityDbContext<ApplicationUser>, it represents a class which uses a custom user entity with a string primary key. For more things, you could refer to the following links.
None
0 Points
6 Posts
How to change primary key for Identity with MySQL as storage provider
Aug 14, 2015 02:23 PM|shyamal890|LINK
I went through this article http://www.asp.net/identity/overview/extensibility/implementing-a-custom-mysql-aspnet-identity-storage-provider and was able to make Identity 2.2.1 work with MySQL as database.
However, as soon as I try follow the link: http://www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity
I come to this instruction -->
Change the context class and user manager to use the key type
In IdentityModels.cs, change the definition of the ApplicationDbContext class to use your new customized classes and an int for the key, as shown in the highlighted code.
However, for MySQL storage provider to work as per http://www.asp.net/identity/overview/extensibility/implementing-a-custom-mysql-aspnet-identity-storage-provider
I had changed the above code from
to
So here, I am facing a problem, there is no extension that MySQLDatabase accepts as IdentityDbContext does. Can anyone please help me out here?
authentication mysql Owin identiy
Star
7980 Points
1586 Posts
Re: How to change primary key for Identity with MySQL as storage provider
Aug 20, 2015 10:32 AM|Weibo Zhang|LINK
Hi shyamal890,
I think the two is not a similar class in this two articles. In the second article, the MySQLDatabase is just a Helper class, you could find out a passage explains that the “MySQLDatabase” contains the MySQL database connection and methods for performing database operations. UserStore and RoleStore are both instantiated with an instance of this class in the “Data access layer classes” section. About the specific code, you could refer to the following link.
https://aspnet.codeplex.com/SourceControl/latest#Samples/Identity/AspNet.Identity.MySQL/MySQLDatabase.cs
For the first ApplicationDbContext which is integrated from IdentityDbContext<ApplicationUser>, it represents a class which uses a custom user entity with a string primary key. For more things, you could refer to the following links.
https://msdn.microsoft.com/en-us/library/dn468176(v=vs.108).aspx
https://msdn.microsoft.com/en-us/library/Dn613255(v=VS.108).aspx
I hope it’s useful to you.
Best Regards,
Weibo Zhang
authentication mysql Owin identiy