productivityinterns / productivitywebapp

A webapp for increasing productivity when filling out forms
MIT License
2 stars 2 forks source link

When attempting to delete an entry, the following error occurs on SaveChange() #12

Closed Connorapple closed 5 years ago

Connorapple commented 5 years ago

Exception has occurred: CLR/Microsoft.EntityFrameworkCore.DbUpdateException An exception of type 'Microsoft.EntityFrameworkCore.DbUpdateException' occurred in Microsoft.EntityFrameworkCore.dll but was not handled in user code: 'An error occurred while updating the entries. See the inner exception for details.' Inner exceptions found, see $exception in variables window for more details. Innermost exception Microsoft.Data.Sqlite.SqliteException : SQLite Error 19: 'FOREIGN KEY constraint failed'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader() at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues) at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)

S4lt5 commented 5 years ago

You have a child that points to a parent that doesn't exist. Check to make sure you didn't accidentally change an Id or something?

On Tue, Jun 11, 2019 at 1:46 PM Connorapple notifications@github.com wrote:

Exception has occurred: CLR/Microsoft.EntityFrameworkCore.DbUpdateException An exception of type 'Microsoft.EntityFrameworkCore.DbUpdateException' occurred in Microsoft.EntityFrameworkCore.dll but was not handled in user code: 'An error occurred while updating the entries. See the inner exception for details.' Inner exceptions found, see $exception in variables window for more details. Innermost exception Microsoft.Data.Sqlite.SqliteException : SQLite Error 19: 'FOREIGN KEY constraint failed'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader() at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues) at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/productivityinterns/productivitywebapp/issues/12?email_source=notifications&email_token=ABEI6AH7O3JUCWAZCJQN6SLPZ7QGXA5CNFSM4HXBT4UKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GY4BBLQ, or mute the thread https://github.com/notifications/unsubscribe-auth/ABEI6AE5G6GYW6J7S7XUBLTPZ7QGXANCNFSM4HXBT4UA .

Connorapple commented 5 years ago

So I don't know how this would be accessing a non-existent parent, or even if this would actually save, having a bit of trouble getting a feel for the way DbSet handles data:

public void SaveFlow(Flow flow)
        {
            //TODO: Save something here!
            Flows.Add(flow);
            SaveChanges();

        }