i created a database as Accountuser , while the table as LogOn on the App directory folder.
on my browser, when i try to register a email and password , i always get this exception. i need your help to resolve this
The model backing the 'GuestBookContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
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: System.InvalidOperationException: The model backing the 'GuestBookContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
Source Error:
Line 36: if (ModelState.IsValid)
Line 37: {
Line 38: var CreUserFind = _db.accountdetails.Find(details.NEmail);
Line 39: if (CreUserFind != null)
Line 40: {
Source File: c:\Users\D doll\Documents\Visual Studio 2012\Projects\GuestBook\GuestBook\Controllers\AccountUserController.cs Line: 38
What I have tried:
using GuestBook.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity.Validation;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace GuestBook.Controllers
{
public class AccountUserController : Controller
{
GuestBookContext _db = new GuestBookContext();
protected override void Dispose(bool disposing)
{
_db.Dispose();
base.Dispose(disposing);
}
[HttpGet]
public ActionResult Registration()
{
return View();
}
[HttpPost]
public ActionResult Registration(LogOn details)
{
ViewBag.validResult = "Null";
if (ModelState.IsValid)
{
var CreUserFind = _db.accountdetails.Find(details.NEmail);
if (CreUserFind != null)
{
ViewBag.validResult = "Email Taken";
ModelState.AddModelError(" ", "The email is already taken");
}
else
{
var CreUser = _db.accountdetails.Create();
var simplecryp = new SimpleCrypto.PBKDF2();
var encrypto = simplecryp.Compute(details.NPassword);
CreUser.NEmail = details.NEmail;
CreUser.NPassword = encrypto;
CreUser.NPasswordSalt = simplecryp.Salt;
CreUser.UserId = Convert.ToString(Guid.NewGuid());
_db.accountdetails.Add(CreUser);
_db.SaveChanges();
ViewBag.validResult = "success";
ModelState.Clear();
ModelState.AddModelError("", "Regitration successfull");
}
}
return View();
for the model class
namespace GuestBook.Models
{
public class LogOn
{
public string UserId { get; set; }
[Key]
[Required(ErrorMessage = "*Enter password")]
[Display(Name = "Password")]
public string NPassword { get; set; }
[Required(ErrorMessage="*Enter email address")]
[Display(Name = "Email Address")]
public string NEmail { get; set; }
public string NPasswordSalt { get; set; }
}
}
for the model db context
namespace GuestBook.Models
{
public class GuestBookContext:DbContext
{
public GuestBookContext() : base("GuestBook") { }
public DbSet<guestbookentry> details { get; set; }
public DbSet<logon> accountdetails { get; set; }
}
}