SQL Server column default value

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
mrmiagi0101
Posts: 23
Joined: Tue 27 Feb 2018 13:43

SQL Server column default value

Post by mrmiagi0101 » Thu 25 Nov 2021 20:23

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?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: SQL Server column default value

Post by Shalex » Fri 26 Nov 2021 16:27

Thank you for your request. We will investigate the question and notify you about the result.

mrmiagi0101
Posts: 23
Joined: Tue 27 Feb 2018 13:43

Re: SQL Server column default value

Post by mrmiagi0101 » Thu 06 Oct 2022 07:00

Any update for this?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: SQL Server column default value

Post by Shalex » Fri 07 Oct 2022 14:53

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.

Post Reply