You have a lot to learn how Doctrine associations work. I suggest spending some time and really reading through the Doctrine Editing Documentation .
A custom object must not use integers. You will probably need the ManyToOne relationship for them (this means: each user can have exactly one country and one province). You should start thinking of things as objects and not try to skip identifiers
For instance:
private $country; private $province;
targetEntity in each of them should be changed to everything that you cause.
If you try to make these changes, make sure you run the app/console doctrine:schema:update command so that your schema updates automatically.
Then you can do this in your controller:
$country = new Country('US'); $entityManager->persist($country); $user->setCountry($country);
Note. I did not assign a country identifier to the setCountry() method. I am passing the actual Country object. This is just an example, and in your actual controller, the $country variable here would be passed through a form or retrieved from a database, etc.
source share