Page 1 of 1

SQL Server column default value

Posted: Thu 25 Nov 2021 20:23
by mrmiagi0101
Hello,

we are using MS SQL Server and EF Core 3(.1) and ED 6.12.1354.

If a column has a default value in database not matching the type of column, this is not a problem for SQL Server.
E.g. colum is nvarchar(16) and default value is 0 (integer), not '0' (nvarchar). If inserting a new row, the value for that column is set to '0'.

But ED creates that config line with 'ValueGeneratedOnAdd' instead of 'ValueGeneratedNever':
HasColumnType(@"nvarchar(16)").ValueGeneratedOnAdd().HasMaxLength(16).HasDefaultValueSql(@"0");
And does not set the property in code to "0".
I guess this is happening because of differnet types?

Is it possible to have the poperty set to the (converted) default value in the autogenerated code of the entity constructor to get rid of the ValueGeneratedOnAdd?

Re: SQL Server column default value

Posted: Fri 26 Nov 2021 16:27
by Shalex
Thank you for your request. We will investigate the question and notify you about the result.

Re: SQL Server column default value

Posted: Thu 06 Oct 2022 07:00
by mrmiagi0101
Any update for this?

Re: SQL Server column default value

Posted: Fri 07 Oct 2022 14:53
by Shalex
Thank you for bringing our attention to this request. As of right now, it is hard to provide any possible time frames.
On the other hand, please rest assured that as soon as we have any update on the process we'll let you know immediately.