mysqlasp.netentity-framework-6asp.net-identitymembership-provider

Unknown column 'Extent1.Discriminator' in 'where clause'


I am using Visual Studio 2013 web form application with MySql database to build a web form application but I have been unable to get past 'Membership and Role Management'. I used a database first approach for the membership and when I try registering a new user, I get the error message below:

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  

Strangely, I do not have an 'Extent1.Discriminator' column anywhere in the database and cannot understand the reason for this frustrating error.


Solution

  • Extent1 is a table alias used by entity framework when it constructs the underlying sql statements. The error means that EF is either not configured correctly or misinterprets your database structure.

    You need to analyise the underlying query it generates and determine why EF us3s a field it is not supposed to. Probably a relationship between 2 tables is incorrectly set up.