Linq To Sql - SQL默认约束问题 [英] Linq To Sql - SQL Default Constraint Problem

查看:142
本文介绍了Linq To Sql - SQL默认约束问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有一个USER表。该表有一个RegistrationDate列,其默认约束为GETDATE()。

I have a USER table in database. The table has a RegistrationDate column which has a default constraint as GETDATE().

使用LINQ时,我不为RegistrationDate列提供任何数据使其为默认值。但SQL Server引发错误。我想LINQ试图插入NULL到列中。

When using LINQ, I don't provide any data for RegistrationDate column to make it default. But SQL Server raises error. I think LINQ tries to insert NULL into the column.

我如何让LINQ不要尝试插入列RegistrationDate,因为它有默认值?

How can I make LINQ not to try to insert in the column RegistrationDate, because it has default value?

推荐答案

自动生成值属性设置为 true 在设计器中。

Set Auto Generated Value property to true in the designer.

IsDbGenerated =true .dbml 文件。

Or IsDbGenerated="true" in .dbml file.

这篇关于Linq To Sql - SQL默认约束问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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