0

The below code was working with SQL Server Compatibility Level 100. However updating to 130, starting making the code below fail. I believe it has to do with the datetime and precision. The item isnt deleted anymore. Any clue why and is there a work around. We want to use some new functions in the 130 level.

_gameJobsRepository.Delete(q => q.GameId == gameJob.GameId && q.DateCreated <= gameJob.DateCreated);
David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341

1 Answers1

0

This is a known issue with EF6 and SQL Server 2016+ in compat level 130+. SQL Server introduced a breaking change, and it broke EF6.

The workarounds are

  • Stay on compat level 120
  • Change all your datetime columns to datetime2
  • Keep all your datetime columns and use a command interceptor to change the parameter types (see the github issue)
  • Migrate to EF Core

Also this might get resolved in EF 6.3, but there's been no commitment, as it looks like a bit of work to fix without introducting breaking changes.

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67
  • When you say might, what do you know? Your name has Microsoft in it. Would changing everything to datetime2 have any negative impacts? – Mike Flynn Apr 25 '19 at 23:31
  • What do I know: I'm not on the team, and know only what I read on GitHub and guess from looking at the source code. As for datetime2, it should "just work" unless you have very old drivers that need to access this database. – David Browne - Microsoft Apr 25 '19 at 23:46