【问题标题】:How to set data type property as smalldatetime如何将数据类型属性设置为 smalldatetime
【发布时间】:2018-03-29 14:26:08
【问题描述】:

有办法吗?以下不起作用:

var customer = constructor.Entity<Customer>();
customer.Property(c => c.Date).DataType("smalldatetime");

【问题讨论】:

    标签: c# ado.net c#-4.0 entity-framework-4 code-first


    【解决方案1】:
    customer.Property(c => c.Date).HasStoreType("smalldatetime");
    

    【讨论】:

      【解决方案2】:

      我的代码优先方法:

      [Table("Customer", Schema = "DBSchema")]
      public class Customer{
      
          [Column("Date", TypeName = "SmallDateTime")]   
          public DateTime Date{ get; set; }
      
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-10-12
        • 1970-01-01
        • 1970-01-01
        • 2021-12-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多