UPDATE 语句与 asp.net mvc 中的 FOREIGN KEY 约束冲突 [关闭]
Posted
技术标签:
【中文标题】UPDATE 语句与 asp.net mvc 中的 FOREIGN KEY 约束冲突 [关闭]【英文标题】:The UPDATE statement conflicted with the FOREIGN KEY constraint in asp.net mvc [closed] 【发布时间】:2021-10-18 17:36:13 【问题描述】:我知道有很多类似的问题,但没有一个可以帮助我解决这个问题。我只是想将 WC_Inbox 表中记录上的Status
的值从Pending
更改为Archived
,但我收到了这个错误。我在这里问的主要原因是因为我不明白外键与我要执行的操作有什么关系。
WC_InboxController.cs
// POST: WC_Inbox/Work/5
// To protect from overposting attacks, enable the specific properties you want to bind to, for
// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Work([Bind(Include = "ID,EncovaID,EmployeeID,District,Org_Number,Hire_Date,Job_Title,Work_Schedule,Injury_Date,Injury_Time,DOT_12,Start_Time,Injured_Body_Part,Side,Missing_Work,Return_to_Work_Date,Doctors_Release,Treatment,Injury_Description,Equipment,Witness,Questioned,Medical_History,Inbox_Submitted,Comments,User_Email,Contact_Email,Specialist_Email,Optional_Email,Optional_Email2,Optional_Email3,Optional_Email4,TX_EROI_lag,Claim_Ruling,Injury_Type,TTD_Onset_Date,Restricted_RTW,Full_Duty_RTW,TTD_Award_notice,RTW_Notice_Carrier,Lost_Time_Start1,Lost_Time_End1,Lost_Time_Start2,Lost_Time_End2,Lost_Time_Start3,Lost_Time_End3,Status,HR_Comments,Add_User,Date_Added,HR_User,Date_Modified")] WC_Inbox wC_Inbox)
if (ModelState.IsValid)
wC_Inbox.HR_User = User.Identity.Name;
wC_Inbox.Date_Modified = DateTime.Now;
db.Entry(wC_Inbox).State = EntityState.Modified;
try
db.SaveChanges();
catch (DbEntityValidationException dbEx)
foreach (var validationErrors in dbEx.EntityValidationErrors)
foreach (var validationError in validationErrors.ValidationErrors)
Trace.TraceInformation("Property: 0 Error: 1", validationError.PropertyName, validationError.ErrorMessage);
return RedirectToAction("Index");
ViewBag.EmployeeID = new SelectList(db.Employees, "ID", "First_Name", wC_Inbox.EmployeeID);
return View(wC_Inbox);
Work.cshtml
@model HR_APP_V2.Models.WC_Inbox
@
ViewBag.Title = "Work";
<h2>Work WC Inbox Form for @ViewBag.Name</h2>
@using (Html.BeginForm())
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true, "", new @class = "text-danger" )
@Html.HiddenFor(model => model.ID)
@Html.Hidden("EmployeeID", (object)ViewBag.EmployeeID)
@Html.Hidden("Add_User", (object)ViewBag.user)
@Html.Hidden("Date_Added", (object)ViewBag.date)
<div class="form-group">
@Html.LabelFor(model => model.District, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.District, new htmlAttributes = new @class = "form-control", placeholder = "0025" )
@Html.ValidationMessageFor(model => model.District, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Org_Number, "Org Number", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Org_Number, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Org_Number, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Hire_Date, "Hire Date", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Hire_Date, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Hire_Date, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Job_Title, "Job Title", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Job_Title, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Job_Title, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Work_Schedule, "Work Schedule", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Work_Schedule, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Work_Schedule, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Injury_Date, "Injury Date", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Injury_Date, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Injury_Date, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Injury_Time, "Injury Time", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Injury_Time, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Injury_Time, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DOT_12, "DOT 12", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
<div class="checkbox">
@Html.EditorFor(model => model.DOT_12)
@Html.ValidationMessageFor(model => model.DOT_12, "", new @class = "text-danger" )
</div>
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Start_Time, "Start Time", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Start_Time, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Start_Time, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Injured_Body_Part, "Injured Body Part", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Injured_Body_Part, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Injured_Body_Part, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Side, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Side, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Side, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Missing_Work, "Missing Work", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
<div class="checkbox">
@Html.EditorFor(model => model.Missing_Work)
@Html.ValidationMessageFor(model => model.Missing_Work, "", new @class = "text-danger" )
</div>
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Return_to_Work_Date, "Return to Work Date", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Return_to_Work_Date, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Return_to_Work_Date, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Doctors_Release, "Doctors Release", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
<div class="checkbox">
@Html.EditorFor(model => model.Doctors_Release)
@Html.ValidationMessageFor(model => model.Doctors_Release, "", new @class = "text-danger" )
</div>
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Treatment, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
<div class="checkbox">
@Html.EditorFor(model => model.Treatment)
@Html.ValidationMessageFor(model => model.Treatment, "", new @class = "text-danger" )
</div>
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Injury_Description, "Injury Description", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Injury_Description, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Injury_Description, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Equipment, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Equipment, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Equipment, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Witness, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Witness, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Witness, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Questioned, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Questioned, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Questioned, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Medical_History, "Medical History", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Medical_History, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Medical_History, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Inbox_Submitted, "Inbox Submitted", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
<div class="checkbox">
@Html.EditorFor(model => model.Inbox_Submitted)
@Html.ValidationMessageFor(model => model.Inbox_Submitted, "", new @class = "text-danger" )
</div>
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Comments, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Comments, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Comments, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.User_Email, "User Email", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.User_Email, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.User_Email, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Contact_Email, "Contact Email", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Contact_Email, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Contact_Email, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Specialist_Email, "Specialist Email", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Specialist_Email, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Specialist_Email, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Optional_Email, "Optional Email", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Optional_Email, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Optional_Email, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Optional_Email2, "Optional Email 2", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Optional_Email2, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Optional_Email2, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Optional_Email3, "Optional Email 3", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Optional_Email3, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Optional_Email3, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Optional_Email4, "Optional Email 4", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Optional_Email4, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Optional_Email4, "", new @class = "text-danger" )
</div>
</div>
<h2 style="text-align: center;">For HR staff use only</h2>
<hr style="border:0px;border-top:1px solid grey;width:75%;" />
<div class="form-group">
@Html.LabelFor(model => model.EncovaID, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.EncovaID, "Encova ID", new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.EncovaID, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.TX_EROI_lag, "TX EROI Lag", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.TX_EROI_lag, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.TX_EROI_lag, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Claim_Ruling, "Claim Ruling", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Claim_Ruling, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Claim_Ruling, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Injury_Type, "Injury Type", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.DropDownList("Injury_Type", new List<SelectListItem>
new SelectListItem Text = "MVA", Value="MVA" ,
new SelectListItem Text = "HEQ", Value="HEQ" ,
new SelectListItem Text = "Tree/Brush", Value="Tree/Brush" ,
new SelectListItem Text = "CTS", Value="CTS" ,
new SelectListItem Text = "HL", Value="HL" ,
new SelectListItem Text = "OP", Value="OP" ,
new SelectListItem Text = "OD NOC", Value="OD NOC"
, new @class = "form-control" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.TTD_Onset_Date, "TTD Onset Date", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.TTD_Onset_Date, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.TTD_Onset_Date, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Restricted_RTW, "Restricted RTW", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Restricted_RTW, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Restricted_RTW, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Full_Duty_RTW, "Full Duty RTW", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Full_Duty_RTW, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Full_Duty_RTW, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.TTD_Award_notice, "TTD Award Notice", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.TTD_Award_notice, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.TTD_Award_notice, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.RTW_Notice_Carrier, "RTW Notice Carrier", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.RTW_Notice_Carrier, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.RTW_Notice_Carrier, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Lost_Time_Start1, "Lost Time Start 1", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Lost_Time_Start1, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Lost_Time_Start1, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Lost_Time_End1, "Lost Time End 1", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Lost_Time_End1, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Lost_Time_End1, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Lost_Time_Start2, "Lost Time Start 2", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Lost_Time_Start2, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Lost_Time_Start2, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Lost_Time_End2, "Lost Time End 2", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Lost_Time_End2, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Lost_Time_End2, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Lost_Time_Start3, "Lost Time Start 3", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Lost_Time_Start3, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Lost_Time_Start3, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Lost_Time_End3, "Lost Time End 3", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.Lost_Time_End3, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.Lost_Time_End3, "", new @class = "text-danger" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Status, htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.DropDownList("Status", new List<SelectListItem>
new SelectListItem Text = "Pending", Value="Pending" ,
new SelectListItem Text = "Active", Value="Active" ,
new SelectListItem Text = "Archived", Value="Archived" ,
, new @class = "form-control" )
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.HR_Comments, "HR Comments", htmlAttributes: new @class = "control-label col-md-2" )
<div class="col-md-10">
@Html.EditorFor(model => model.HR_Comments, new htmlAttributes = new @class = "form-control" )
@Html.ValidationMessageFor(model => model.HR_Comments, "", 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>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts
@Scripts.Render("~/bundles/jqueryval")
Employee.cs
//------------------------------------------------------------------------------
// <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 HR_APP_V2.Models
using System;
using System.Collections.Generic;
public partial class Employee
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Employee()
this.WC_Inbox = new HashSet<WC_Inbox>();
public int ID get; set;
public string First_Name get; set;
public string Last_Name get; set;
public string Gender get; set;
public string Marital_Status get; set;
public Nullable<int> SSN get; set;
public string Address get; set;
public string Phone_Number get; set;
public string Add_User get; set;
public Nullable<System.DateTime> Date_Added get; set;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<WC_Inbox> WC_Inbox get; set;
WC_Inbox.cs
//------------------------------------------------------------------------------
// <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 HR_APP_V2.Models
using System;
using System.Collections.Generic;
public partial class WC_Inbox
public long ID get; set;
public int EmployeeID get; set;
public int? District get; set;
public int? Org_Number get; set;
public System.DateTime? Hire_Date get; set;
public string Job_Title get; set;
public int? Work_Schedule get; set;
public System.DateTime? Injury_Date get; set;
public string Injury_Time get; set;
public bool DOT_12 get; set;
public string Start_Time get; set;
public string Injured_Body_Part get; set;
public string Side get; set;
public bool Missing_Work get; set;
public Nullable<System.DateTime> Return_to_Work_Date get; set;
public Nullable<bool> Doctors_Release get; set;
public Nullable<bool> Treatment get; set;
public string Injury_Description get; set;
public string Equipment get; set;
public string Witness get; set;
public string Questioned get; set;
public string Medical_History get; set;
public bool Inbox_Submitted get; set;
public string Comments get; set;
public string User_Email get; set;
public string Contact_Email get; set;
public string Specialist_Email get; set;
public string Optional_Email get; set;
public string Optional_Email2 get; set;
public string Optional_Email3 get; set;
public string Optional_Email4 get; set;
public string Add_User get; set;
public System.DateTime Date_Added get; set;
public string EncovaID get; set;
public Nullable<System.DateTime> TX_EROI_lag get; set;
public string Claim_Ruling get; set;
public string Injury_Type get; set;
public Nullable<System.DateTime> TTD_Onset_Date get; set;
public Nullable<System.DateTime> Restricted_RTW get; set;
public Nullable<System.DateTime> Full_Duty_RTW get; set;
public Nullable<System.DateTime> TTD_Award_notice get; set;
public Nullable<System.DateTime> RTW_Notice_Carrier get; set;
public Nullable<System.DateTime> Lost_Time_Start1 get; set;
public Nullable<System.DateTime> Lost_Time_End1 get; set;
public Nullable<System.DateTime> Lost_Time_Start2 get; set;
public Nullable<System.DateTime> Lost_Time_End2 get; set;
public Nullable<System.DateTime> Lost_Time_Start3 get; set;
public Nullable<System.DateTime> Lost_Time_End3 get; set;
public string HR_Comments get; set;
public string HR_User get; set;
public Nullable<System.DateTime> Date_Modified get; set;
public string Status get; set;
public virtual Employee Employee get; set;
在我的 SQL 数据库中,员工 ID 列上的外键关系已设置为 Cascade
,正如在类似帖子中提到的那样。
我还能尝试解决这个问题吗?
【问题讨论】:
【参考方案1】:尝试在隐藏字段中使用模型,因为 ViewBag 数据不会被回发
@Html.HiddenFor(model => model.EmployeeID)
@Html.HiddenFor(model => model.Add_User)
@Html.HiddenFor(model => model.Date_Added)
并从操作中删除绑定,因为恕我直言,您不需要它
public ActionResult Work( WC_Inbox wC_Inbox)
【讨论】:
谢尔盖你总是来救援。再次感谢您,效果很好。 @GrillOwner69420 不客气。以上是关于UPDATE 语句与 asp.net mvc 中的 FOREIGN KEY 约束冲突 [关闭]的主要内容,如果未能解决你的问题,请参考以下文章
ASP.NET MVC 中的 ASP.NET AJAX 与 jQuery
ASP.NET MVC 中的 jQuery 与 MicrosoftAjax
从asp.net mvc中的switch case调用javascript函数