29 Replies
this is the exception I get ^
an error duplicate key makes me think you are writing nested object which should have been removed and that are already in the db
what should I do in this case?
Does it tell you what field contains the duplicate key?
oh, didn't see the expand button on that error log
let me read
@daminko what does your voyage entity look like?
show your voyage repo as well
pls code format that
sure sorry
ty
np
Is
Transporteur
the entity that references ASP users?ok, and are you trying to create a new voyage for an existing user?
yep
existing users
the transporteur, and two magasiniers or the transporteur, and a magasinier and also a demandeur
normally to avoid stuff like this I have an explicit foreign key property for my navigations
I've already done this, no?
but I'd try setting
Utilisateur
to something that's like
I didn't see one for Utilisateur (which I think is what's causing your current error)ow
OWWWW
I c
so what's happening is that EF sees it as a NEW user and is trying to add a new row to the DB
rather than just setting the foreign key column on the new Transporteur row
so it's not binded?
cuz when creating a transporteur I create at the sametime a utilisateur
not sure what you mean by binded in this case
I mean when I get the send a create query to the db I send two queries the first creates an utilisateur and the second creates a transporteur

this is how i'm doing
what does that
CreateUtilisateur
method look like?Sec
show the user manager code too
my guess is you're creating this with a different dbcontext instance that is disposed of, so the original entity is no longer being tracked
but again that's just a guess
aight thanks