# Value inside FK field not getting inserted

**URL:** <https://forum.shopware.com/t/value-inside-fk-field-not-getting-inserted/66405>\
**Category:** Programming (EN)\
**Created:** [21. April 2020 um 11:44 UTC](https://forum.shopware.com/t/value-inside-fk-field-not-getting-inserted/66405 "2020-04-21T11:44:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohsin94j](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mohsin94j](https://forum.shopware.com/u/mohsin94j)\
**Post date:** [21. April 2020 um 11:44 UTC](https://forum.shopware.com/t/value-inside-fk-field-not-getting-inserted/66405/1 "2020-04-21T11:44:51Z")

</div>

I am following Shopware 6 developer training and their we made a foreign key relation with the County Entity.

This is my Migration file:

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/2/2d3b51873fe3dc745d23e2f7ea63ad3394ca566a.png)

This is my Entity Definition:

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/b/b5f2eafed202b7de6b6b6826e9efe5f5dc505bc3.png)

This is my Entity:

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/6/6a8e61e26de635923f16c3647e5628c33ec22a85.png)

This is my controller where i am trying to save the data:

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/0/0f5551f7988cb2b083ea3429ba45924ece7d9104.png)

&nbsp;

\_ **country\_id** \_ field in the database doesn’t get the value when the data is inserted via Insomnia API client. Even if i write this ‚random‘ instead of \_ **$countryId** \_ - it still doesn’t get the value and is always empty.

&nbsp;

Any ideas what could be wrong?&nbsp; ![Frown](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/frown.png "Frown")

---

<div class="post-metadata">

**Author:** ![mohsin94j](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mohsin94j](https://forum.shopware.com/u/mohsin94j)\
**Post date:** [21. April 2020 um 11:46 UTC](https://forum.shopware.com/t/value-inside-fk-field-not-getting-inserted/66405/2 "2020-04-21T11:46:43Z")

</div>

Although the array \_ **$data** \_ does get the \_ **Id** \_ of the country in it, but it just doesn’t get set in the database field.

---

<div class="post-metadata">

**Author:** ![mohsin94j](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mohsin94j](https://forum.shopware.com/u/mohsin94j)\
**Post date:** [23. April 2020 um 13:10 UTC](https://forum.shopware.com/t/value-inside-fk-field-not-getting-inserted/66405/3 "2020-04-23T13:10:25Z")

</div>

Any idea?

---

<div class="post-metadata">

**Author:** ![mohsin94j](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mohsin94j](https://forum.shopware.com/u/mohsin94j)\
**Post date:** [24. April 2020 um 21:07 UTC](https://forum.shopware.com/t/value-inside-fk-field-not-getting-inserted/66405/4 "2020-04-24T21:07:35Z")

</div>

Why is this forum dead? Or there is no community support for English speakers ?&nbsp;

---

<div class="post-metadata">

**Author:** ![shyim](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/shyim/32/7681_2.png) [@shyim](https://forum.shopware.com/u/shyim)\
**Post date:** [24. April 2020 um 22:40 UTC](https://forum.shopware.com/t/value-inside-fk-field-not-getting-inserted/66405/5 "2020-04-24T22:40:57Z")

</div>

Your property is wrong. It has to be countryId

---

<div class="post-metadata">

**Author:** ![mohsin94j](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mohsin94j](https://forum.shopware.com/u/mohsin94j)\
**Post date:** [25. April 2020 um 14:32 UTC](https://forum.shopware.com/t/value-inside-fk-field-not-getting-inserted/66405/6 "2020-04-25T14:32:14Z")

</div>

I changed it but it was like that in video tutorial of developer training as well. But i changed that and still no **country\_id** in table.

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/1/1666e8d6505f1ab639d1762e6e2aa17e68c3efa1.png)

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/2/2fd78c7e999a739f3376b1abc31a84d0b6f23c92.png)

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/a/a52d335cc92e603acc81abd4df3a1dc3450831bf.png)

---

<div class="post-metadata">

**Author:** ![shyim](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/shyim/32/7681_2.png) [@shyim](https://forum.shopware.com/u/shyim)\
**Post date:** [25. April 2020 um 16:07 UTC](https://forum.shopware.com/t/value-inside-fk-field-not-getting-inserted/66405/7 "2020-04-25T16:07:58Z")

</div>

You still use in the generate country\_id. It must be countryId

---

<div class="post-metadata">

**Author:** ![mohsin94j](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mohsin94j](https://forum.shopware.com/u/mohsin94j)\
**Post date:** [25. April 2020 um 16:20 UTC](https://forum.shopware.com/t/value-inside-fk-field-not-getting-inserted/66405/8 "2020-04-25T16:20:54Z")

</div>

After changing it to countryId in generate method, now i am getting this error. I also changed in entity getter setter method from country\_id to countryId and changed column name in table from country\_id to countryId still same error. Reverted back entity and column name to country\_id

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/b/b991bda3d9af23edef8f5d3c566dbf49bb73552e.png)
