Force Entity Framework 5 to use datetime2 data type

前端 未结 2 1450
情话喂你
情话喂你 2020-12-05 05:10

Is it possible to globally set Entity Framework DbContext to use datetime2 for all properties that are System.DateTime when using Code

2条回答
  •  感情败类
    2020-12-05 05:35

    Not in EF5 but EF6 (currently in alpha version) allow this with custom conventions. For EF5 you would need some custom convention based framework based on reflection which would add HasColumnType calls to model builder through reflection - check for example EF Code First Extras (it claims to have support for pluggable conventions).

提交回复
热议问题