how to delete entries only from child table using dotnet core | delete existing on dorpdown edit

preview_player
Показать описание
Hello Friends
in this video, I have explained that how you can delete data from the child table only (It should not be deleted from parent) using dot net core
so when we update record using multi-select dropdown with checkbox with code first approach, then previous record must be deleted and new one should be insterted from the child reference table .
you can find out the code in the first comment of the video.
If you face below error:

InvalidOperationException: The instance of entity type 'Employee' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values.

then solution is before second dbcontext operation :
_context.ChangeTracker.Clear();

you can message me your query on my instagram

#rctechlife #updatemultiselectvalueoneditusingdotnetcore #updatereferencetableonmultiselectdropdownselection
#rinkuchoudhary #developerslife #codelovers
Рекомендации по теме
Комментарии
Автор

thank you maim at the time nobody to give crud with multiplecheck dropdownlist this video is very helpfull for me because i am fresher again more thanks

SandeepMWTStudent
Автор

var existingempdepts = _context.employees.Include(x => => x.Id == employee.Id);
foreach (var empdepts in
_context.Remove(empdepts);
_context.SaveChanges();

rinkuchoudhary
welcome to shbcf.ru