Linq-to-SQL会忽略SQL Server的默认值 [英] Linq-to-SQL ignores SQL Server default value

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

问题描述

在使用Linq-to-SQL时,在现有表中添加一列,并在该新列上设置默认值,Linq to SQL似乎会忽略默认值. 有没有其他人经历过这种行为?有没有办法解决此问题,以便Linq-to-SQL或SQL Server自动设置默认值?

When using Linq-to-SQL, adding a column to an existing table, and setting a default value on that new column, it seems that Linq to SQL ignores the default value. Has anyone else experienced this behaviour? Is there a way to fix it, so that Linq-to-SQL or SQL Server automatically sets the default value?

我添加的列的类型为Bit,默认值设置为1.

The column I added was of type Bit, with a default value set to 1.

推荐答案

我现在通过使用我需要将其传递给部分数据上下文类,因为每次您更改dbml中的某些内容时,默认类都会被自动覆盖.

I needed to pass this into a partial datacontext class, as the default one is automatically overwritten every time you change something in the dbml.

这篇关于Linq-to-SQL会忽略SQL Server的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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