开发者

Linq To Sql - SQL Default Constraint Problem

开发者 https://www.devze.com 2022-12-28 13:00 出处:网络
I have a 开发者_JAVA技巧USER table in database. The table has a RegistrationDate column which has a default constraint as GETDATE().

I have a 开发者_JAVA技巧USER table in database. The table has a RegistrationDate column which has a default constraint as GETDATE().

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.

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


Set Auto Generated Value property to true in the designer.

Or IsDbGenerated="true" in .dbml file.


I am not 100% sure, but you could make the property read-only in the DBML designer.

0

精彩评论

暂无评论...
验证码 换一张
取 消