WebSecurity.CreateAccount fails for MySQL

2019-07-24 19:28发布

问题:

I am using WebMatrix and stuck at the first place while trying to create users in MySQL database.

The error message is in line:

var token = WebSecurity.CreateAccount(email, password, requireEmailConfirmation);

Error message:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[UserId] FROM [UserProfile] WHERE (UPPER([Email]) = 'TE3ST@TEST.DE')'

I can fully understand that the server is trying to use SQL formatted query to MySQL server. How do I recompile or tell the WebSecurity.CreateAccount to use MySQL formatted queries?

Any idea?

Thank you in advance krish

回答1:

The WebSecurity helper is a wrapper around the SimpleMembership Provider which doesn't support MySQL (at the moment, at least). It only supports SQL Server and SQL Compact 4.0. You can write your own membership provider which inherits ExtendedMembershipProvider if you need MySQL support.