SaveChanges方法不是将数据插入数据库,而是在删除时有效

时间:2017-08-23 18:49:42

标签: c# asp.net entity-framework

  <section>
    <h2>Explore New Videos!</h2>
    <iframe width="700" height="397" src="https://unsplash.it/200" frameborder="0" allowfullscreen >
    </iframe>
  </section>
  <aside>
    <div class = "news-feed">
        <img src="https://unsplash.it/700" height="15%" width="5%">
        <div class = "summary">
          <p>This is text</p>
        </div>
    </div>
  </aside>

上述代码中的EmployeeDbContex contex = new EmployeeDbContex(); tbl_Employee Employee = new tbl_Employee(); Employee.Name = txtname.Text.Trim(); Employee.Address = txtAddress.Text.Trim(); Employee.Salary = Convert.ToDecimal(txtSalary.Text.Trim()); Employee.Gender = ddGender.SelectedItem.Text; Employee.ContactNo = txtContact.Text.Trim(); contex.tbl_Employee.Add(Employee); contex.SaveChanges(); 方法无效。这些值分配给属性,但在插入新数据时不会在数据库中进行更改。

然而,当我执行删除时,它完美无缺。当我在调试模式下检查程序时,控件只是通过SaveChanges()方法,并没有跳转到此方法的定义。

0 个答案:

没有答案