When updating database I get a EntityValidationErrorSQL update from one Table to another based on a ID matchSQL update query using joinsHow can I do an UPDATE statement with JOIN in SQL?Update a table using JOIN in SQL Server?Model Validation problem when render same model twice pn same pageMySQL error code: 1175 during UPDATE in MySQL WorkbenchASP.NET MVC 5 Scaffolding not creating elements for enum propertyFilling Dropdownlist on a value coming from another DropdownHow to filter DropDown list by logged in User in MVCHow to save list of children with its parent in Kendo UI MVC?

What caused the tendency for conservatives to not support climate change regulations?

Understanding STM32 datasheet regarding decoupling capacitors

Rotated Position of Integers

How should I push back against my job assigning "homework"?

Can a non-EU citizen travel within the Schengen area without identity documents?

Can a helicopter mask itself from Radar?

What does "Marchentalender" on the front of a postcard mean?

Term for checking piece whose opponent daren't capture it

Smart people send dumb people to a new planet on a space craft that crashes into a body of water

What are the slash markings on Gatwick's 08R/26L?

What are the benefits of cryosleep?

etoolbox: AtBeginEnvironment is not At Begin Environment

The term for the person/group a political party aligns themselves with to appear concerned about the general public

How can a single Member of the House block a Congressional bill?

Biblical Basis for 400 years of silence between old and new testament

What is the difference between nullifying your vote and not going to vote at all?

Why the lack of hesitance to wear pads on the sabbath?

Can a rogue effectively triple their speed by combining Dash and Ready?

How can I offer a test ride while selling a bike?

Do creatures all have the same statistics upon being reanimated via the Animate Dead spell?

What is the indigenous Russian word for a wild boar?

Asking bank to reduce APR instead of increasing credit limit

Could I be denied entry into Ireland due to medical and police situations during a previous UK visit?

How to properly maintain eye contact with people that have distinctive facial features?



When updating database I get a EntityValidationError


SQL update from one Table to another based on a ID matchSQL update query using joinsHow can I do an UPDATE statement with JOIN in SQL?Update a table using JOIN in SQL Server?Model Validation problem when render same model twice pn same pageMySQL error code: 1175 during UPDATE in MySQL WorkbenchASP.NET MVC 5 Scaffolding not creating elements for enum propertyFilling Dropdownlist on a value coming from another DropdownHow to filter DropDown list by logged in User in MVCHow to save list of children with its parent in Kendo UI MVC?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I'm trying to get the logged in user to edit his profile. For now I decided to use a satic userID (since using the sessions usedID was also giving me errors). Now when I run the code it goes through all the lines but at the end it gives me this error "EntityValidationErrors".



I just want the code to update the current UserID's Bio, Sex, and preferred sex



[HttpPost]
public ActionResult FillProfile(tblUser user)

using (TrinityEntities db = new TrinityEntities())

var id = Session["userID"];
user.Id = 1018; //Convert.ToInt32(id);

SqlConnection conn = new SqlConnection(@"Data Source = (LocalDB)MSSQLLocalDB; AttachDbFilename = C:UsersRubenDesktopPeriode 2PersoonlijkTrinityTrinityTrinityApp_DataTrinity.mdf; Integrated Security = True; MultipleActiveResultSets = True; Connect Timeout = 30; Application Name = EntityFramework");

conn.Open();

string Query = "SELECT FirstName, LastName, Email, Password, Age FROM tblUser WHERE Id='" + user.Id + "'";

using (SqlCommand command = new SqlCommand(Query, conn))

SqlDataReader reader = command.ExecuteReader();

while (reader.Read())

user.FirstName = reader[0] as string;
user.LastName = reader[1] as string;
user.Email = reader[2] as string;
user.Password = reader[3] as string;
string Sage = reader[4] as string;
user.Age = Convert.ToInt32(Sage);
break;


db.Entry(user).State = EntityState.Modified;
db.SaveChanges();


conn.Close();

return RedirectToAction("Index", "Home");




View:



@model Trinity.Models.tblUser

@
ViewBag.Title = "Profile";

// prevent login by alterring adress
if (Session["userID"] == null)

Response.Redirect("~/Login/Index");



<h2>Let's fill you profile!</h2>

@using (Html.BeginForm("FillProfile", "Profile", FormMethod.Post))

@Html.AntiForgeryToken()

<div class="form-horizontal">
<hr />

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.Sex, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.DropDownListFor(model => model.Sex,
new List<SelectListItem>
new SelectListItem Value = "Male" , Text = "Male" ,
new SelectListItem Value = "Female" , Text = "Female" ,
,
new @class = "control-label col-md-2" )
@Html.ValidationMessageFor(model => model.Sex, "", new @class = "text-danger" )
</div>
</div>

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.Preffered, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.DropDownListFor(model => model.Preffered,
new List<SelectListItem>
new SelectListItem Value = "Female" , Text = "Female" ,
new SelectListItem Value = "Male" , Text = "Male" ,
new SelectListItem Value = "Both" , Text = "Both"
,
new @class = "control-label col-md-2" )
@Html.ValidationMessageFor(model => model.Preffered, "", new @class = "text-danger" )
</div>
</div>

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.BIO, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.TextAreaFor(model => model.BIO, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.BIO, "", new @class = "text-danger" )
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<label class="label-success">@ViewBag.SuccessMessage</label>
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<label class="label-warning">@ViewBag.AlreadyRegisteredMessage</label>
</div>
</div>


@section Scripts
@Scripts.Render("~/bundles/jqueryval")



Model classes:



//-------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//-------------------------------------------------------------------------

namespace Trinity.Models

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

public partial class tblUser

public int Id get; set;

[DisplayName("First Name")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^[^Wd_]+$", ErrorMessage = "Only letters allowed in your name")]

public string FirstName get; set;

[DisplayName("Last Name")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^[^Wd_]+$", ErrorMessage = "Only letters allowed in your name")]
public string LastName get; set;

public string BIO get; set;

[DisplayName("E-Mail")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*", ErrorMessage = "Incorrect E-mail Format")]
public string Email get; set;

[DataType(DataType.Password)]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^.*(?=.8,)(?=.*[d])(?=.*[W]).*$", ErrorMessage = "Password must be 8 characters, contain at least 1 digit and one special character")]
public string Password get; set;

[DisplayName("Confirm Password")]
[DataType(DataType.Password)]
// [Required(ErrorMessage = "This field is required")]
[Compare("Password", ErrorMessage ="Passwords are not the same")]
public string ConfirmPassword get; set;

public string Photo get; set;

[DisplayName("Age")]
// [Required(ErrorMessage = "This field is required")]
public int Age get; set;

public string Sex get; set;
public string Preferred get; set;











share|improve this question
























  • Please provide User model class

    – Hien Nguyen
    Mar 24 at 13:29











  • Added the database model class!

    – im_ Ruben
    Mar 26 at 20:19











  • @HienNguyen updated the question

    – im_ Ruben
    Mar 27 at 9:06

















1















I'm trying to get the logged in user to edit his profile. For now I decided to use a satic userID (since using the sessions usedID was also giving me errors). Now when I run the code it goes through all the lines but at the end it gives me this error "EntityValidationErrors".



I just want the code to update the current UserID's Bio, Sex, and preferred sex



[HttpPost]
public ActionResult FillProfile(tblUser user)

using (TrinityEntities db = new TrinityEntities())

var id = Session["userID"];
user.Id = 1018; //Convert.ToInt32(id);

SqlConnection conn = new SqlConnection(@"Data Source = (LocalDB)MSSQLLocalDB; AttachDbFilename = C:UsersRubenDesktopPeriode 2PersoonlijkTrinityTrinityTrinityApp_DataTrinity.mdf; Integrated Security = True; MultipleActiveResultSets = True; Connect Timeout = 30; Application Name = EntityFramework");

conn.Open();

string Query = "SELECT FirstName, LastName, Email, Password, Age FROM tblUser WHERE Id='" + user.Id + "'";

using (SqlCommand command = new SqlCommand(Query, conn))

SqlDataReader reader = command.ExecuteReader();

while (reader.Read())

user.FirstName = reader[0] as string;
user.LastName = reader[1] as string;
user.Email = reader[2] as string;
user.Password = reader[3] as string;
string Sage = reader[4] as string;
user.Age = Convert.ToInt32(Sage);
break;


db.Entry(user).State = EntityState.Modified;
db.SaveChanges();


conn.Close();

return RedirectToAction("Index", "Home");




View:



@model Trinity.Models.tblUser

@
ViewBag.Title = "Profile";

// prevent login by alterring adress
if (Session["userID"] == null)

Response.Redirect("~/Login/Index");



<h2>Let's fill you profile!</h2>

@using (Html.BeginForm("FillProfile", "Profile", FormMethod.Post))

@Html.AntiForgeryToken()

<div class="form-horizontal">
<hr />

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.Sex, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.DropDownListFor(model => model.Sex,
new List<SelectListItem>
new SelectListItem Value = "Male" , Text = "Male" ,
new SelectListItem Value = "Female" , Text = "Female" ,
,
new @class = "control-label col-md-2" )
@Html.ValidationMessageFor(model => model.Sex, "", new @class = "text-danger" )
</div>
</div>

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.Preffered, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.DropDownListFor(model => model.Preffered,
new List<SelectListItem>
new SelectListItem Value = "Female" , Text = "Female" ,
new SelectListItem Value = "Male" , Text = "Male" ,
new SelectListItem Value = "Both" , Text = "Both"
,
new @class = "control-label col-md-2" )
@Html.ValidationMessageFor(model => model.Preffered, "", new @class = "text-danger" )
</div>
</div>

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.BIO, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.TextAreaFor(model => model.BIO, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.BIO, "", new @class = "text-danger" )
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<label class="label-success">@ViewBag.SuccessMessage</label>
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<label class="label-warning">@ViewBag.AlreadyRegisteredMessage</label>
</div>
</div>


@section Scripts
@Scripts.Render("~/bundles/jqueryval")



Model classes:



//-------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//-------------------------------------------------------------------------

namespace Trinity.Models

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

public partial class tblUser

public int Id get; set;

[DisplayName("First Name")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^[^Wd_]+$", ErrorMessage = "Only letters allowed in your name")]

public string FirstName get; set;

[DisplayName("Last Name")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^[^Wd_]+$", ErrorMessage = "Only letters allowed in your name")]
public string LastName get; set;

public string BIO get; set;

[DisplayName("E-Mail")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*", ErrorMessage = "Incorrect E-mail Format")]
public string Email get; set;

[DataType(DataType.Password)]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^.*(?=.8,)(?=.*[d])(?=.*[W]).*$", ErrorMessage = "Password must be 8 characters, contain at least 1 digit and one special character")]
public string Password get; set;

[DisplayName("Confirm Password")]
[DataType(DataType.Password)]
// [Required(ErrorMessage = "This field is required")]
[Compare("Password", ErrorMessage ="Passwords are not the same")]
public string ConfirmPassword get; set;

public string Photo get; set;

[DisplayName("Age")]
// [Required(ErrorMessage = "This field is required")]
public int Age get; set;

public string Sex get; set;
public string Preferred get; set;











share|improve this question
























  • Please provide User model class

    – Hien Nguyen
    Mar 24 at 13:29











  • Added the database model class!

    – im_ Ruben
    Mar 26 at 20:19











  • @HienNguyen updated the question

    – im_ Ruben
    Mar 27 at 9:06













1












1








1








I'm trying to get the logged in user to edit his profile. For now I decided to use a satic userID (since using the sessions usedID was also giving me errors). Now when I run the code it goes through all the lines but at the end it gives me this error "EntityValidationErrors".



I just want the code to update the current UserID's Bio, Sex, and preferred sex



[HttpPost]
public ActionResult FillProfile(tblUser user)

using (TrinityEntities db = new TrinityEntities())

var id = Session["userID"];
user.Id = 1018; //Convert.ToInt32(id);

SqlConnection conn = new SqlConnection(@"Data Source = (LocalDB)MSSQLLocalDB; AttachDbFilename = C:UsersRubenDesktopPeriode 2PersoonlijkTrinityTrinityTrinityApp_DataTrinity.mdf; Integrated Security = True; MultipleActiveResultSets = True; Connect Timeout = 30; Application Name = EntityFramework");

conn.Open();

string Query = "SELECT FirstName, LastName, Email, Password, Age FROM tblUser WHERE Id='" + user.Id + "'";

using (SqlCommand command = new SqlCommand(Query, conn))

SqlDataReader reader = command.ExecuteReader();

while (reader.Read())

user.FirstName = reader[0] as string;
user.LastName = reader[1] as string;
user.Email = reader[2] as string;
user.Password = reader[3] as string;
string Sage = reader[4] as string;
user.Age = Convert.ToInt32(Sage);
break;


db.Entry(user).State = EntityState.Modified;
db.SaveChanges();


conn.Close();

return RedirectToAction("Index", "Home");




View:



@model Trinity.Models.tblUser

@
ViewBag.Title = "Profile";

// prevent login by alterring adress
if (Session["userID"] == null)

Response.Redirect("~/Login/Index");



<h2>Let's fill you profile!</h2>

@using (Html.BeginForm("FillProfile", "Profile", FormMethod.Post))

@Html.AntiForgeryToken()

<div class="form-horizontal">
<hr />

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.Sex, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.DropDownListFor(model => model.Sex,
new List<SelectListItem>
new SelectListItem Value = "Male" , Text = "Male" ,
new SelectListItem Value = "Female" , Text = "Female" ,
,
new @class = "control-label col-md-2" )
@Html.ValidationMessageFor(model => model.Sex, "", new @class = "text-danger" )
</div>
</div>

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.Preffered, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.DropDownListFor(model => model.Preffered,
new List<SelectListItem>
new SelectListItem Value = "Female" , Text = "Female" ,
new SelectListItem Value = "Male" , Text = "Male" ,
new SelectListItem Value = "Both" , Text = "Both"
,
new @class = "control-label col-md-2" )
@Html.ValidationMessageFor(model => model.Preffered, "", new @class = "text-danger" )
</div>
</div>

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.BIO, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.TextAreaFor(model => model.BIO, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.BIO, "", new @class = "text-danger" )
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<label class="label-success">@ViewBag.SuccessMessage</label>
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<label class="label-warning">@ViewBag.AlreadyRegisteredMessage</label>
</div>
</div>


@section Scripts
@Scripts.Render("~/bundles/jqueryval")



Model classes:



//-------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//-------------------------------------------------------------------------

namespace Trinity.Models

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

public partial class tblUser

public int Id get; set;

[DisplayName("First Name")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^[^Wd_]+$", ErrorMessage = "Only letters allowed in your name")]

public string FirstName get; set;

[DisplayName("Last Name")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^[^Wd_]+$", ErrorMessage = "Only letters allowed in your name")]
public string LastName get; set;

public string BIO get; set;

[DisplayName("E-Mail")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*", ErrorMessage = "Incorrect E-mail Format")]
public string Email get; set;

[DataType(DataType.Password)]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^.*(?=.8,)(?=.*[d])(?=.*[W]).*$", ErrorMessage = "Password must be 8 characters, contain at least 1 digit and one special character")]
public string Password get; set;

[DisplayName("Confirm Password")]
[DataType(DataType.Password)]
// [Required(ErrorMessage = "This field is required")]
[Compare("Password", ErrorMessage ="Passwords are not the same")]
public string ConfirmPassword get; set;

public string Photo get; set;

[DisplayName("Age")]
// [Required(ErrorMessage = "This field is required")]
public int Age get; set;

public string Sex get; set;
public string Preferred get; set;











share|improve this question
















I'm trying to get the logged in user to edit his profile. For now I decided to use a satic userID (since using the sessions usedID was also giving me errors). Now when I run the code it goes through all the lines but at the end it gives me this error "EntityValidationErrors".



I just want the code to update the current UserID's Bio, Sex, and preferred sex



[HttpPost]
public ActionResult FillProfile(tblUser user)

using (TrinityEntities db = new TrinityEntities())

var id = Session["userID"];
user.Id = 1018; //Convert.ToInt32(id);

SqlConnection conn = new SqlConnection(@"Data Source = (LocalDB)MSSQLLocalDB; AttachDbFilename = C:UsersRubenDesktopPeriode 2PersoonlijkTrinityTrinityTrinityApp_DataTrinity.mdf; Integrated Security = True; MultipleActiveResultSets = True; Connect Timeout = 30; Application Name = EntityFramework");

conn.Open();

string Query = "SELECT FirstName, LastName, Email, Password, Age FROM tblUser WHERE Id='" + user.Id + "'";

using (SqlCommand command = new SqlCommand(Query, conn))

SqlDataReader reader = command.ExecuteReader();

while (reader.Read())

user.FirstName = reader[0] as string;
user.LastName = reader[1] as string;
user.Email = reader[2] as string;
user.Password = reader[3] as string;
string Sage = reader[4] as string;
user.Age = Convert.ToInt32(Sage);
break;


db.Entry(user).State = EntityState.Modified;
db.SaveChanges();


conn.Close();

return RedirectToAction("Index", "Home");




View:



@model Trinity.Models.tblUser

@
ViewBag.Title = "Profile";

// prevent login by alterring adress
if (Session["userID"] == null)

Response.Redirect("~/Login/Index");



<h2>Let's fill you profile!</h2>

@using (Html.BeginForm("FillProfile", "Profile", FormMethod.Post))

@Html.AntiForgeryToken()

<div class="form-horizontal">
<hr />

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.Sex, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.DropDownListFor(model => model.Sex,
new List<SelectListItem>
new SelectListItem Value = "Male" , Text = "Male" ,
new SelectListItem Value = "Female" , Text = "Female" ,
,
new @class = "control-label col-md-2" )
@Html.ValidationMessageFor(model => model.Sex, "", new @class = "text-danger" )
</div>
</div>

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.Preffered, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.DropDownListFor(model => model.Preffered,
new List<SelectListItem>
new SelectListItem Value = "Female" , Text = "Female" ,
new SelectListItem Value = "Male" , Text = "Male" ,
new SelectListItem Value = "Both" , Text = "Both"
,
new @class = "control-label col-md-2" )
@Html.ValidationMessageFor(model => model.Preffered, "", new @class = "text-danger" )
</div>
</div>

@Html.ValidationSummary(true, "", new @class = "text-danger" )
<div class="form-group">
@Html.LabelFor(model => model.BIO, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.TextAreaFor(model => model.BIO, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.BIO, "", new @class = "text-danger" )
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<label class="label-success">@ViewBag.SuccessMessage</label>
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<label class="label-warning">@ViewBag.AlreadyRegisteredMessage</label>
</div>
</div>


@section Scripts
@Scripts.Render("~/bundles/jqueryval")



Model classes:



//-------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//-------------------------------------------------------------------------

namespace Trinity.Models

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

public partial class tblUser

public int Id get; set;

[DisplayName("First Name")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^[^Wd_]+$", ErrorMessage = "Only letters allowed in your name")]

public string FirstName get; set;

[DisplayName("Last Name")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^[^Wd_]+$", ErrorMessage = "Only letters allowed in your name")]
public string LastName get; set;

public string BIO get; set;

[DisplayName("E-Mail")]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*", ErrorMessage = "Incorrect E-mail Format")]
public string Email get; set;

[DataType(DataType.Password)]
// [Required(ErrorMessage = "This field is required")]
[RegularExpression(@"^.*(?=.8,)(?=.*[d])(?=.*[W]).*$", ErrorMessage = "Password must be 8 characters, contain at least 1 digit and one special character")]
public string Password get; set;

[DisplayName("Confirm Password")]
[DataType(DataType.Password)]
// [Required(ErrorMessage = "This field is required")]
[Compare("Password", ErrorMessage ="Passwords are not the same")]
public string ConfirmPassword get; set;

public string Photo get; set;

[DisplayName("Age")]
// [Required(ErrorMessage = "This field is required")]
public int Age get; set;

public string Sex get; set;
public string Preferred get; set;








asp.net-mvc sql-update httphandler






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 21:56









marc_s

591k13311301278




591k13311301278










asked Mar 24 at 10:16









im_ Rubenim_ Ruben

378




378












  • Please provide User model class

    – Hien Nguyen
    Mar 24 at 13:29











  • Added the database model class!

    – im_ Ruben
    Mar 26 at 20:19











  • @HienNguyen updated the question

    – im_ Ruben
    Mar 27 at 9:06

















  • Please provide User model class

    – Hien Nguyen
    Mar 24 at 13:29











  • Added the database model class!

    – im_ Ruben
    Mar 26 at 20:19











  • @HienNguyen updated the question

    – im_ Ruben
    Mar 27 at 9:06
















Please provide User model class

– Hien Nguyen
Mar 24 at 13:29





Please provide User model class

– Hien Nguyen
Mar 24 at 13:29













Added the database model class!

– im_ Ruben
Mar 26 at 20:19





Added the database model class!

– im_ Ruben
Mar 26 at 20:19













@HienNguyen updated the question

– im_ Ruben
Mar 27 at 9:06





@HienNguyen updated the question

– im_ Ruben
Mar 27 at 9:06












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322730%2fwhen-updating-database-i-get-a-entityvalidationerror%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322730%2fwhen-updating-database-i-get-a-entityvalidationerror%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript