这里有一个问题,我正在尝试查询一个数据库,当我从该查询中选择一些东西时,我得到了这个错误
Schema specified is not valid. Errors:
Models.Context.AdaptEntities.ssdl(2,58) : error 0172: All SSDL artifacts must target the same provider. The Provider 'MySql.Data.MySqlClient' is different from 'MySql.Data.MySqlClient' that was encountered earlier.
Models.Context.AdaptEntities.ssdl(2,91) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '2008' is different from '5.6' that was encountered earlier.
Models.Context.Unitemps.ssdl(2,54) : error 0172: All SSDL artifacts must target the same provider. The Provider 'MySql.Data.MySqlClient' is different from 'MySql.Data.MySqlClient' that was encountered earlier.
Models.Context.Unitemps.ssdl(2,87) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '2008' is different from '5.6' that was encountered earlier.
有人知道解决方案吗?
最佳答案
问题是您没有针对正确版本的 MySQL。
首先是根据 ProviderManifestToken 中指定的 MySQL 版本检查 Transact-SQL 查询的 Entity Framework 目标。存储模型 (.ssdl) 文件中 Schema 元素的属性。
此版本可能与您连接的实际 MySQL 版本不同。
这是 Entity Framework 的一个已知问题... Taken from here
“某些数据库行为取决于为数据库设置的兼容级别。如果您的 ProviderManifestToken 属性设置为 2005 并且您的 SQL Server 版本为 2005,但数据库的兼容级别设置为“80”(SQL Server 2000 ),生成的 Transact-SQL 将以 SQL Server 2005 为目标,但由于兼容级别设置可能无法按预期执行。例如,如果 ORDER BY 列表中的列名与选择器。”
解决方法:打开 Entity Framework .edmx 文件并手动更改 ProviderManifestToken。这应该在编译后更改 ssdl 文件中指定的 list token (用于离线)。
关于c# - "MetadataException, Schema specified is not valid",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22069418/