大网数据广告活动
服务器运维问答

MySql Membership provider - Missing or incorrect schema

· 52CE 我爱测

We have an ASP.NET site running on IIS 7.5 with a MySQL database using the .net connector, the membership/role providers are set in the web.config correctly and they work - but only temporarily. Historically (.net connector 6.7.4…

问题原文

原帖链接 · Sam Pickering · CC BY-SA 3.0

We have an ASP.NET site running on IIS 7.5 with a MySQL database using the .net connector, the membership/role providers are set in the web.config correctly and they work - but only temporarily.

Historically (.net connector 6.7.4.0 and prior) we always had an issue after restoring site backups including the membership tables, we'd get an error on the page saying we had a "missing or incorrect schema" for the membership provider, which is nonsense because we can see the tables clearly in the DB.

To solve this we'd simply delete the membership tables from the DB, set autogenerateschema=true in the web.config, let the role provider auto-generate the tables again, which works. We can then restore from our backup (the same backup!) and overwrite the new blank tables with our existing accounts and everything works fine. We figured this was just a quirk with the .net connector and because it only happened after restoring the DB from backups we weren't too fussed.

Now we've upgraded to .net connector 6.9.4.0 we're getting the same problem, only it's worse because now if the app pool is restarted for that website it triggers the same "missing or incorrect schema" message and we have apply the fix above. Doing things like making changes to the web.config trigger an app pool cycle which means we cannot make changes to the web.config without downing the site!

This is the role provider from the web.config with some details omitted, it's never changed other than us manually updating the version number.

<roleManager defaultProvider="MySQLRoleProvider" enabled="true">
      <providers>
        <clear />
        <add name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.9.4.0, Culture=neutral, PublicKeyToken=xxxxxx" applicationName="xxxxx" connectionStringName="xxxxxx" autogenerateschema="True" />
      </providers>
    </roleManager>

It should be noted that after triggering that error and applying our fix, we restore the membership tables from the exact same backup, this means the tables are identical before/after the fix, so it cannot be a problem with the database, it's some internal state of IIS.

已采纳解答

原帖链接 · Sam Pickering · CC BY-SA 3.0

I've figured this out, you need to update the schema version stored in the database itself, you can do this manually by running this SQL against the database.

UPDATE my_aspnet_schemaversion SET version = 10

Replace 10 with whatever version is appropriate for the connector you've downloaded.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-10-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。