Using database default values with Linq to SQL codewise
Posted
by Ivo
on Stack Overflow
See other posts from Stack Overflow
or by Ivo
Published on 2010-05-12T07:03:12Z
Indexed on
2010/05/12
9:14 UTC
Read the original article
Hit count: 197
I am using Dynamic Data with linq to SQL and SQL Server 2008.
I have a GUID column that gets his value from the default value with newguid(). When I set IsDbGenerated to true in the designer it works like a charm.
But when I renew table this property is set back to false again. So I added it to the metadata. For some reason it's not being pickup, "00000000-0000-0000-0000-000000000000" is being inserted in database. The displayname and readonly change are being pick up.
What am I missing?
[MetadataType(typeof(CMS_Data_HistoryMetadata))] public partial class CMS_Data_History {
} [TableName("Content")] public class CMS_Data_HistoryMetadata { [DisplayName("Pagina Title")] public object pageTitleBar { get; set; } [ReadOnly(true)] [DisplayName("Versie")] public object version_date { get; set; } [ColumnAttribute(IsDbGenerated = true)] public object entity_id; }
© Stack Overflow or respective owner