Scaffolding doesn't generate default values
See original GitHub issueScaffolding doesn’t generate default values, and I wonder if there is a way to enforce it.
Ideally I would expect [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
attribute in models.
e.g.:
Source
[CreatedAt] DATETIME2 (3) CONSTRAINT [DF_importQueue_CreatedAt] DEFAULT (sysutcdatetime()) NOT NULL,
[SoftDelete] BIT CONSTRAINT [DF_importQueue_SoftDelete] DEFAULT ((1)) NOT NULL,
Actual
public DateTime CreatedAt { get; set; }
public bool SoftDelete { get; set; }
Expected
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public DateTime CreatedAt { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public bool SoftDelete { get; set; }
// OR at least
// public bool SoftDelete { get; set; } = true;
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Scaffold-dbcontext not generating HasDefaultValueSql ...
Since a few versions ago the Scaffold-dbcontext command doesn't seem to be generating .HasDefaultValueSql("...") fluid code anymore for database ...
Read more >Scaffold and default values - Get Help and Help Others
So I created a scaffold based on the schema, but all the creationdate should had a default value as now, instead form marked...
Read more >Scaffold generator does not generate stories or tests
After generating several scaffolds for our app, I noticed that it generates very little testing and no stories.
Read more >Generated Values - EF Core
This page details various patterns for configuration value generation with EF Core. Default values. On relational databases, a column can be ...
Read more >Scaffolding (Reverse Engineering) - EF Core
The scaffolding process can be controlled by various command line options. Specifying tables and views. By default, all tables and views in the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Lack of rights to the Azure SQL db, known issue.