Linq To Sql - SQL默认约束问题 [英] Linq To Sql - SQL Default Constraint Problem
问题描述
我在数据库中有一个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屋!