映射到日期而不是CTP5中的DateTime [英] Mapping to a Date instead of DateTime in CTP5
问题描述
我的某个模型上有一个Birthdate属性,并希望它映射到SQL中的Date字段。
我尝试使用 [DataType(DataType。)进行装饰。日期)],但没有用。后来我想出了这个方法 - modelBuilder.Entity< Client>()。Property(p => p.BirthDate).HasColumnType(" date"); - 工作正常。
支持[DataType]属性提示数据类型是不是有意义?
Chris Sutton
Chris,
感谢您的建议。我们将考虑增加对此的支持。
亚瑟跨度> 跨度>
I have a Birthdate property on one of my models and wanted it to map to a Date field in SQL.
I tried decorating it with [DataType(DataType.Date)], which didn't work. Later I figured out this method - modelBuilder.Entity<Client>().Property(p => p.BirthDate).HasColumnType("date"); - which worked fine.
Wouldn't it make sense to support the [DataType] attribute to hint the datatype?
Chris Sutton
Chris,
Thanks for the suggestion. We will consider adding support for this.
Arthur
这篇关于映射到日期而不是CTP5中的DateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!