I am working on an API using Entity Framework and i added new models to the template model. when i do a migration, it is successful but when i run an update database from package manager console, it returns an error that says 'invalid column 'imagepath' in table asp.netusers'. please i do not know what else to do and i am sure the column exist in my table. below is my identity model
public class ApplicationUser : IdentityUser
{
//public string Username { get; set; }
//illustrates many bookings to one user
public ICollection<Booking> Bookings { get; set; }
//illustrates many feedacks to one user
public ICollection<Feedback> feedbacks { get; set; }
public string Alias { get; set; }
//public string Address { get; set; }
public DateTime DateCreated { get; set; }
public string MobileNumber { get; set; }
[NotMapped]
public byte[] ImageArray { get; set; }
public string ImagePath { get; set; }
below is my account controller
[Required]
[Display(Name = "Email")]
[RegularExpression(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$", ErrorMessage = "Email in not valid")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
//custom Model
//[Required]
//[Display(Name ="Address")]
//[StringLength(100,ErrorMessage ="Enter a Valid Address"),MinLength(10)]
// public string Address { get; set; }
public DateTime DateCreated { get; set; }
[Required][Display(Name ="Mobile Number")]
[RegularExpression("^[0-9]*$", ErrorMessage = "Invalid Phone Number")]
[StringLength(11, ErrorMessage = "The {0} must be at least {2} characters long."), MinLength(6)]
public string MobileNumber { get; set; }
////[Required]
//[Display(Name = "User name")]
////[MaxLength(10, ErrorMessage = "The {0} must be at least {2} characters long."), MinLength(6)]
//public string Username { get; set; }
[StringLength(11, ErrorMessage = "The {0} must be at least {2} characters long."), MinLength(2)]
public string Alias { get; set; }
public string ImagePath { get; set; }
public byte[] ImageArray { get; set; }
lastly below is my AccountController class
public async Task<IHttpActionResult> Register( RegisterBindingModel model)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
else
{
var stream = new MemoryStream(model.ImageArray);
var guid = Guid.NewGuid().ToString();
var file = string.Format("{0}.jpg", guid);
var folder = "~\\Content\\UserData";
var fullpath = string.Format("{0}\\{1}", folder, file);
var response = FileHelper.UploadPhoto(stream, folder, file);
var user = new ApplicationUser()
{
UserName = model.Alias,
Email = model.Email,
DateCreated = model.DateCreated,
MobileNumber = model.MobileNumber,
Alias = model.Alias,
ImagePath = fullpath
};
IdentityResult result = await UserManager.CreateAsync(user, model.Password);
if (!result.Succeeded)
{
return GetErrorResult(result);
}
return Ok(user);
The error comes up with 'invalid column "Imagepath" on asp.net-user table' and i am sure i have the column because i have saved in the column before.