Hi!
MSSQL 2008, LLBLGEN 4.6, target Linq2Sql, C#
Table definition
CREATE TABLE [dbo].[myTable](
[Id] [int] IDENTITY(1,1) NOT NULL,
[UserId] [int] NOT NULL,
[Date] [datetime] NOT NULL,
CONSTRAINT [PK_idmp_Submission] PRIMARY KEY CLUSTERED ([Id] ASC) ON [PRIMARY]) ON [PRIMARY]
ALTER TABLE [dbo].[myTable] ADD CONSTRAINT [DV_myTable_Date] DEFAULT (sysutcdatetime()) FOR [Date]
Created property:
/// <summary>Gets or sets the Date field. Mapped on target field 'Date'. </summary>
[Column(Name="Date", Storage="_date", CanBeNull=false, DbType="datetime NOT NULL")]
public System.DateTime Date
{
get { return _date; }
set
{
if((_date != value))
{
OnDateChanging(value);
SendPropertyChanging("Date");
_date = value;
SendPropertyChanged("Date");
OnDateChanged();
}
}
}
Unfortunately the default value does not get written to the database. I tried setting the property in the entity to readonly, which results in no setter is created for the property, but still the wrong value is written to the table (0001-01-01 00:00:00.000000) and so an error is thrown: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
If I manually add an entry to the table, the correct current DateTime value (UTC) is written.
I'd like to NOT edit the generated source code manually but somehow edit the LLBLGEN project setting to properly NOT write a value at all to the table, but let the database do it's job writing the default value.
One problem seems to be in the generated code: eventhough the column has a default value, the attribute IsDbGenerated is missing. If this is added, the field is set correctly.
Any hint on that?