无法将Null插入列中! [英] Cannot insert Null into column!

查看:80
本文介绍了无法将Null插入列中!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个名为SearchDate的列表,我已经将属性设置为默认的Getdate()和nullable(null不允许

现在当我运行我的应用程序并尝试插入记录时,我收到错误消息 - 无法将Null插入
列SearchDate !!

我有点认为GetDate()函数会处理这个... ..即插入新记录
GetDate()函数会插入日期: - /

推荐答案

您好brucey54,

Hi brucey54,

请在SearchDate属性中添加以下属性。

Please add the following attribute on your SearchDate property.

public partial class yourmodelcalss
    {
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int Id { get; set; }

        [Required, DatabaseGenerated(DatabaseGeneratedOption.Computed)]
        public DateTime SearchDate { get; set; }

        [StringLength(50)]
        public string Name { get; set; }
    }

祝你好运,

Cole Wu


这篇关于无法将Null插入列中!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆