1

I am having this problem while running scaffold-dbcontext, it is representing SQL Server date columns as datetime.

Is there any solution?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
jonrexh
  • 49
  • 4
  • Not yet. [Support for DateOnly and TimeOnly](https://github.com/dotnet/efcore/issues/24507) is expected in EF Core 7. You can use custom converters to map `date` to `DateOnly` properties – Panagiotis Kanavos Aug 23 '22 at 15:34
  • `DateOnly` and `TimeOnly` are not yet supported naturally in EF Core/ADO.NET, so probably that's why EF Core scaffolding is not using it. – Ivan Stoev Aug 23 '22 at 15:35
  • @PanagiotisKanavos Indeed. But OP wants scaffolding (reverse engineering, model type property is generated, out of control), so value converters are not an option – Ivan Stoev Aug 23 '22 at 15:37
  • The change can be made afterwards. There's no other option right now – Panagiotis Kanavos Aug 23 '22 at 15:43
  • You can use the T4 templates in EF Core 7 to fo this. – ErikEJ Aug 23 '22 at 19:02

0 Answers0