Skip to content

Scaffold uses system's comma separator for HasDefaultValue #35654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Quietscheente opened this issue Feb 19, 2025 · 7 comments · Fixed by #35675
Closed

Scaffold uses system's comma separator for HasDefaultValue #35654

Quietscheente opened this issue Feb 19, 2025 · 7 comments · Fixed by #35675

Comments

@Quietscheente
Copy link

Quietscheente commented Feb 19, 2025

Bug description

I have a german Windows 10 and with Scaffold (8.0.8)
a default value set in the database (SQL Server 13.0) with
ALTER TABLE [dbo].[Foo] ADD CONSTRAINT [DF_Foo_weight] DEFAULT ((1.0)) FOR [weight] becomes a entity.Property(e => e.Weight).HasDefaultValue(10.0);
in the DbContext.
If I change the comma separator in the Region settings to "." it is HasDefaultValue(1.0) as expected.

Your code

USE [BIS]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Foo](
	[id] [int] IDENTITY(1,1) NOT NULL,	
	[weight] [float] NOT NULL,	
 CONSTRAINT [PK_Foo] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY])
GO

ALTER TABLE [dbo].[Foo] ADD  CONSTRAINT [DF_Foo_weight]  DEFAULT ((1.0)) FOR [weight]
GO
        modelBuilder.Entity<Foo>(entity =>
        {
            entity.Property(e => e.Weight).HasDefaultValue(10.0);
        });
[Table("Foo")]
public partial class Foo
{
    [Key]
    [Column("id")]
    public int Id { get; set; }

    [Column("weight")]
    public double Weight { get; set; }
}

Stack traces


Verbose output


EF Core version

8.0.8

Database provider

No response

Target framework

.NET 8

Operating system

Windows 10

IDE

No response

@Quietscheente Quietscheente changed the title Scaffold ignores system's comma separator for HasDefaultValue Scaffold uses system's comma separator for HasDefaultValue Feb 19, 2025
@ErikEJ
Copy link
Contributor

ErikEJ commented Feb 19, 2025

Please share the full CREATE TABLE statement

@Quietscheente
Copy link
Author

I created a minimal example

USE [BIS]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Foo](
	[id] [int] IDENTITY(1,1) NOT NULL,	
	[weight] [float] NOT NULL,	
 CONSTRAINT [PK_Foo] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY])
GO

ALTER TABLE [dbo].[Foo] ADD  CONSTRAINT [DF_Foo_weight]  DEFAULT ((1.0)) FOR [weight]
GO
        modelBuilder.Entity<Foo>(entity =>
        {
            entity.Property(e => e.Weight).HasDefaultValue(10.0);
        });
[Table("Foo")]
public partial class Foo
{
    [Key]
    [Column("id")]
    public int Id { get; set; }

    [Column("weight")]
    public double Weight { get; set; }
}

ErikEJ added a commit to ErikEJ/EFCorePowerTools that referenced this issue Feb 21, 2025
ErikEJ added a commit to ErikEJ/EFCorePowerTools that referenced this issue Feb 21, 2025
@roji
Copy link
Member

roji commented Feb 23, 2025

@roji Happy to submit a PR!

Sure, that'd be great!

@roji roji marked this as a duplicate of #35676 Feb 24, 2025
@roji roji changed the title Scaffold uses system's comma separator for HasDefaultValue SQL Server: scaffold uses system's comma separator for HasDefaultValue Feb 24, 2025
@roji roji changed the title SQL Server: scaffold uses system's comma separator for HasDefaultValue Scaffold uses system's comma separator for HasDefaultValue Feb 24, 2025
@AndriySvyryd AndriySvyryd added this to the 10.0.0 milestone Feb 24, 2025
@zimaa77
Copy link

zimaa77 commented Mar 14, 2025

Would be possible to merge this fix into 8.0.x release?

@ErikEJ
Copy link
Contributor

ErikEJ commented Mar 14, 2025

@zimaa77 The fix is in EF Core Power Tools CLI for EF Core 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants