You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If a column in your database is defined with a DEFAULT supplied by the schema, the code generated by dotnet ef dbcontext scaffold will include both .HasDefaultValueSql (with the DEFAULT supplied by the schema) and HasDefaultValue (with the regular default applied to all normal columns). This causes an exception when trying to execute the project:
System.InvalidOperationException: DefaultValue cannot be set for 'my_column' at the same time as DefaultValueSql. Remove one of these configurations.
To Reproduce
Steps to reproduce the behavior:
Create a database table including, e.g., [my_column] [tinyint] NOT NULL DEFAULT 3,
Run dotnet ef dbcontext scaffold on that database
Try to create a dbcontext object and run it to observe the runtime exception
Expected behavior
The normally generated .HasDefaultValue should be omitted if there's already a .HasDefaultValueSql configuration specified.
Desktop (please complete the following information):
OS: Windows 10
EntityFrameworkCore.FSharp 6.0.7
Microsoft.EntityFrameworkCore 6.0.7
dotnet-ef 6.0.7
The text was updated successfully, but these errors were encountered:
Describe the bug
If a column in your database is defined with a DEFAULT supplied by the schema, the code generated by
dotnet ef dbcontext scaffold
will include both.HasDefaultValueSql
(with the DEFAULT supplied by the schema) andHasDefaultValue
(with the regular default applied to all normal columns). This causes an exception when trying to execute the project:To Reproduce
Steps to reproduce the behavior:
[my_column] [tinyint] NOT NULL DEFAULT 3,
dotnet ef dbcontext scaffold
on that databaseExpected behavior
The normally generated
.HasDefaultValue
should be omitted if there's already a.HasDefaultValueSql
configuration specified.Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: