none
Issue updating database .NET Core 1.1.2 and EF 1.1.2 RRS feed

  • Question

  • I am using .NET Core 1.1.2, and EF 1.1.2... I have a simple site that I built for a school teacher for managing yearbook stuff... Everything went swimmingly up until I ran into an EF issue...

    I have a very simple .NET Razor View for managing yearbook page layout... There are no images and it is a simple "standard" razor view with page numbers and contents text list... I have slightly modified the list into two columns... Left column is EVEN numbered pages... The right side is ODD Numbered pages (as you if you are looking at a text representation of a book)... I managed to do the layout using FLEX, and it works great... Auto adjusts, etc...

    My issue is with page numbering... My class is very simple... "Page" SQL table has three columns... PageID, PageNumber, and Contents... (int identity, int, varchar(100) respectively). What i need to do is keep page numbers in sync as the user does CRUD operations on the list... Seems very simple, and NORMALLY I would use an "insert trigger" on the Page table in SQL and simply adjust the pagenumber column up or down depending on the inserted, deleted item... However, EF Core (or EF in general) doesn't seem to like Insert, Update, Delete triggers very much... or at all... 

    I have attempted to update the records directly using EF Linq queries in subsequent function calls inside the PagesController to update the records, but this seems to hang, and doesn't always work properly... I have tried other solutions found on the internet... and I finally tried calling a stored procedure... NOPE! So... What the HECK!

    Can anyone provide some guidance here... Everything with this particular functionality is working great... I just can't wrap my head around where to go with this monstrosity! Any help would be appreciated!!! 


    ME

    Wednesday, August 16, 2017 7:24 PM

All replies

  • Hi Stewart_Bash,

    Thank you for posting here.

    >>I have attempted to update the records directly using EF Linq queries in subsequent function calls inside the PagesController to update the records, but this seems to hang, and doesn't always work properly

    Coule you provide more information about your error? What hangs the update of records? Could you provide some code for us to reproduce the error?

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 18, 2017 6:00 AM
    Moderator
  • Usually in your scenario, I'll just use EntityCommand to execute update query to add page number by 1 if the book id matches and the page number is greater than the to-be-inserted page, refresh the local view and then do the insert.

    Use the POCO object to update the pages would be much slower (for each such page record to be updated, an update statement will be generated for that record, instead of just one update statement that updates all), especially if the book has lots of page and you're inserting an early page.



    Friday, August 18, 2017 6:23 AM
    Answerer