'where clause' 中的未知列 'Extent1.Discriminator'
Unknown column 'Extent1.Discriminator' in 'where clause'
我正在使用 Visual Studio 2013 Web 表单应用程序和 MySql 数据库来构建 Web 表单应用程序,但我无法通过 'Membership and Role Management'。
我对会员资格使用了数据库优先方法,当我尝试注册新用户时,收到以下错误消息:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: MySql.Data.MySqlClient.MySqlException: Unknown column 'Extent1.Discriminator' in 'where clause'
Source Error:
Line 16: var manager = new UserManager();
Line 17: var user = new ApplicationUser() { UserName = UserName.Text };
Line 18: IdentityResult result = manager.Create(user, Password.Text);
Line 19: if (result.Succeeded)
Line 20: {
Source File: c:\WebsiteProjects\ASPNETWebProjects\RevenuePortal\RevenuePortal\Account\Register.aspx.cs
奇怪的是,我在数据库中的任何地方都没有 'Extent1.Discriminator' 列,我无法理解这个令人沮丧的错误的原因。
Extent1 是 entity framework 在构造基础 sql 语句时使用的 table 别名。该错误意味着 EF 未正确配置或误解了您的数据库结构。
您需要分析它生成的基础查询并确定为什么 EF 使用了它不应该使用的字段。可能是 2 table 之间的关系设置不正确。
如果可能,尝试从头开始迁移。从下方执行 Nuget 包 manager:VS 2019 - 工具 - NuGet 包管理器 - 包管理器控制台 - 运行 命令 Add-Migration DBInit
- 一旦完成,运行 另一个命令 Update-Database
.
以上解决方案适用于代码优先方法。
我在更改系统时遇到了同样的问题,迁移后它开始为我工作。希望同样适用于其他人。编程愉快!!
我正在使用 Visual Studio 2013 Web 表单应用程序和 MySql 数据库来构建 Web 表单应用程序,但我无法通过 'Membership and Role Management'。 我对会员资格使用了数据库优先方法,当我尝试注册新用户时,收到以下错误消息:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: MySql.Data.MySqlClient.MySqlException: Unknown column 'Extent1.Discriminator' in 'where clause'
Source Error:
Line 16: var manager = new UserManager();
Line 17: var user = new ApplicationUser() { UserName = UserName.Text };
Line 18: IdentityResult result = manager.Create(user, Password.Text);
Line 19: if (result.Succeeded)
Line 20: {
Source File: c:\WebsiteProjects\ASPNETWebProjects\RevenuePortal\RevenuePortal\Account\Register.aspx.cs
奇怪的是,我在数据库中的任何地方都没有 'Extent1.Discriminator' 列,我无法理解这个令人沮丧的错误的原因。
Extent1 是 entity framework 在构造基础 sql 语句时使用的 table 别名。该错误意味着 EF 未正确配置或误解了您的数据库结构。
您需要分析它生成的基础查询并确定为什么 EF 使用了它不应该使用的字段。可能是 2 table 之间的关系设置不正确。
如果可能,尝试从头开始迁移。从下方执行 Nuget 包 manager:VS 2019 - 工具 - NuGet 包管理器 - 包管理器控制台 - 运行 命令 Add-Migration DBInit
- 一旦完成,运行 另一个命令 Update-Database
.
以上解决方案适用于代码优先方法。
我在更改系统时遇到了同样的问题,迁移后它开始为我工作。希望同样适用于其他人。编程愉快!!