You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList`1 entries)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges()
Inner exception:
Unable to cast object of type 'System.Data.SqlClient.SqlParameter' to type 'Microsoft.Data.SqlClient.SqlParameter'.
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDateTimeTypeMapping.ConfigureParameter(DbParameter parameter)
at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping.CreateParameter(DbCommand command, String name, Object value, Nullable`1 nullable)
at Microsoft.EntityFrameworkCore.Storage.Internal.TypeMappedRelationalParameter.AddDbParameter(DbCommand command, Object value)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalParameterBase.AddDbParameter(DbCommand command, IReadOnlyDictionary`2 parameterValues)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.CreateCommand(RelationalCommandParameterObject parameterObject, Guid commandId, DbCommandMethod commandMethod)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
Further technical details
EF Core version: 3.1.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Framework 4.7.2
Operating system: Windows 10 (1809)
IDE: Visual Studio 2019 16.3
The text was updated successfully, but these errors were encountered:
Thanks for pointing that out, I was about to note that changing the column definition [ExpiryDate] [date] NULL to [ExpiryDate] [datetime] NULL works. That wouldn't have dealt with the root cause though.
I've updated to use Microsoft.Data.SqlClient throughout this application and that's fixed the issue.
Is it safe / possible to use Microsoft.Data.SqlClient everywhere that System.Data.SqlClient is currently used - e.g. I have a library that is shared between different applications using EF Core and LINQ-to-SQL, can I update the library to use Microsoft.Data.SqlClient and the old L2S applications will still be OK?
@LordBenjamin I'm not familiar with LINQ-to-SQL, although I'm guessing it may not be possible for it to work with Microsoft.Data.SqlClient. However, it should be OK to have the same application with EF Core using M.D.SqlClient, and L2S using S.D.SqlClient. As a general rule M.D.SqlClient is very compatible with S.D.SqlClient, and since it's more actively developed, it will contain more fixes and features as time goes on.
Called
SaveChanges()
after adding a simple entity.Expected entity to be saved - actually got an exception.
Steps to reproduce
I haven't put together a minimum repro yet, but my method essentially looks like this:
Inner exception:
Further technical details
EF Core version: 3.1.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Framework 4.7.2
Operating system: Windows 10 (1809)
IDE: Visual Studio 2019 16.3
The text was updated successfully, but these errors were encountered: