Click here to Skip to main content
14,825,800 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello!
I have a created an MVC project, connected with my SQL management data base.

When I execute my application, and try to login or create a new user I have an error:
Server Error in '/'.

Invalid column name 'Email'.
Invalid column name 'EmailConfirmed'.
Invalid column name 'PhoneNumber'.
Invalid column name 'PhoneNumberConfirmed'.
Invalid column name 'TwoFactorEnabled'.
Invalid column name 'LockoutEndDateUtc'.
Invalid column name 'LockoutEnabled'.
Invalid column name 'AccessFailedCount'.

Description: An unhandled exception occurred during the execution of the current web request. For more information about the error and where it originated in the code, see the stack trace. 

Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'Email'. 
Invalid column name 'EmailConfirmed'. 
Invalid column name 'PhoneNumber'. 
Invalid column name 'PhoneNumberConfirmed'. 
Invalid column name 'TwoFactorEnabled'. 
Invalid column name 'LockoutEndDateUtc'. 
Invalid column name 'LockoutEnabled'. 
Invalid column name 'AccessFailedCount'. 

Source Error: 


Riga 46:             if (ModelState.IsValid)
Riga 47:             {
Riga 48:                 var user = await UserManager.FindAsync(model.UserName, model.Password);
Riga 49:                 if (user != null)
Riga 50:                 {

File di origine: c:\Users\newbreaker\Desktop\Examen Web 2017\WebProjet2\WebProjet2\Controllers\AccountController.cs    Riga: 48 


What am I missing?

What I have tried:

// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
    if (ModelState.IsValid)
    {
        var user = await UserManager.FindAsync(model.UserName, model.Password);
        if (user != null)
        {
            await SignInAsync(user, model.RememberMe);
            return RedirectToLocal(returnUrl);
        }
        else
        {
            ModelState.AddModelError("", "Invalid username or password.");
        }
    }

    // If we got this far, something failed, redisplay form
    return View(model);
}


On my Web.config I have:
<connectionStrings>
  <add name="DefaultConnection" connectionString="Data Source=NEWBREAKER12\SQL2014;Initial Catalog=WebShop;Integrated Security=True" providerName="System.Data.SqlClient" />
<appSettings>


On my Models -> IdentityModels I have:
public ApplicationDbContext()
    : base("DefaultConnection", throwIfV1Schema: false)
{
}
Posted
Updated 24-Jan-17 10:33am

Check your DB: it's saying that the columns names it lists don't exist in the table you are trying to access.
So start by checking it's the right connection string for that specific version of the DB, and check the table definition against your model.
   
Comments
Francesco Bigi 24-Jan-17 7:47am
   
Thank you for you answer OriginalGriff;
I created a new db an made again the project and now is working.
It seem that I have modified too many times and it wasn't recognising the tables.

:)
OriginalGriff 24-Jan-17 8:16am
   
Easily done - you're welcome!
Thank you for you answer OriginalGriff;
I created a new db an made again the project and now is working.
It seem that I have modified too many times and it wasn't recognising the tables.

:)
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900