# Foreign Key reference error during updation

**URL:** <https://forum.codewithmosh.com/t/foreign-key-reference-error-during-updation/2071>\
**Category:** ASP.NET MVC\
**Created:** [January 18, 2021, 8:27pm UTC](https://forum.codewithmosh.com/t/foreign-key-reference-error-during-updation/2071 "2021-01-18T20:27:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rejul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/rejul/32/695_2.png) [@rejul](https://forum.codewithmosh.com/u/rejul)\
**Post date:** [January 18, 2021, 8:27pm UTC](https://forum.codewithmosh.com/t/foreign-key-reference-error-during-updation/2071/1 "2021-01-18T20:27:53Z")

</div>

Please help!

error link  
due to upload limit : here is the error

> _The UPDATE statement conflicted with the FOREIGN KEY constraint “FK\_dbo.Customers\_dbo.MembershipTypes\_MembershipTypeId”. The conflict occurred in database “aspnet-Zently-20210105074420”, table “dbo.MembershipTypes”, column ‘Id’.  
> The statement has been terminated._

**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.Data.SqlClient.SqlException: The UPDATE statement conflicted with the FOREIGN KEY constraint “FK\_dbo.Customers\_dbo.MembershipTypes\_MembershipTypeId”. The conflict occurred in database “aspnet-Zently-20210105074420”, table “dbo.MembershipTypes”, column ‘Id’.  
The statement has been terminated.

**Source Error:**

`Line 80: Line 81: } Line 82: _context.SaveChanges(); Line 83: return RedirectToAction("Index","Customers"); Line 84: }`

 ![error](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/3b354bc26c53e5dcee30fb94e28713dc50b95550.png)

Many are having same issue !

> <https://github.com/mosh-hamedani/vidly-mvc-5/commit/e7fb4e6973bbcf640780e44e18f3c12344460138#r28642531>

---

<div class="post-metadata">

**Author:** ![rejul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/rejul/32/695_2.png) [@rejul](https://forum.codewithmosh.com/u/rejul)\
**Post date:** [January 18, 2021, 8:28pm UTC](https://forum.codewithmosh.com/t/foreign-key-reference-error-during-updation/2071/2 "2021-01-18T20:28:49Z")

</div>

![error1](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/08328db0b4ab0810de6c38db3fcd02d334c0ed67.png)

---

<div class="post-metadata">

**Author:** ![rejul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/rejul/32/695_2.png) [@rejul](https://forum.codewithmosh.com/u/rejul)\
**Post date:** [January 18, 2021, 9:08pm UTC](https://forum.codewithmosh.com/t/foreign-key-reference-error-during-updation/2071/3 "2021-01-18T21:08:50Z")

</div>

Fixed the issue… it was just nametypo issue

---

<div class="post-metadata">

**Author:** ![Adedamola](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@Adedamola](https://forum.codewithmosh.com/u/Adedamola)\
**Post date:** [June 22, 2021, 8:53am UTC](https://forum.codewithmosh.com/t/foreign-key-reference-error-during-updation/2071/4 "2021-06-22T08:53:16Z")

</div>

How did fix this specifically?
