Present Chozo
Present Chozo
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
I'd have to dig deeper into your code and DB to troubleshoot this.
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
Yeah, I'm stumped, unfortunately.
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
Maybe show both of the repo classes for both entities?
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
See if that also throws an error.
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
If the change tracker is already tracking it, memory = await memoryRepo.GetAsync(memory.Id) shouldn't call the DB.
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
Try getting getting the most up-to-date instance of that Memory object prior to deleting it.
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
Are you using FindAsync() or FirstOrDefault()?
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
If you're using a repo pattern, I assume you have a Get method, right?
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
Hmmm...
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
Or I guess a better question is "Is the DbContext you're using to delete the entity the same one you used to add it?"
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
And do you know for sure that your change tracker is tracking that entity when you try and delete it?
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
I'm guessing the Memory object also has its Id populated by the time you try and delete it, right?
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
But even from that excerpt it seems like something didn't save correctly.
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
Sure.
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
...well, one you can publically share, I guess.
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
Do you have a stack trace?
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
Try declaring it like this:
var memoryPerson = new MemoryPerson()
{
Memory = memory,
Person = person
};
var memoryPerson = new MemoryPerson()
{
Memory = memory,
Person = person
};
46 replies
CC#
Created by Gax on 12/22/2024 in #help
Deleting an entity with a many-to-many relationship throws an ArgumentNullException
Your problem is how you're declaring your MemoryPerson, I think.
46 replies