question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scaffolding doesn't generate default values

See original GitHub issue

Scaffolding 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:closed
  • Created 2 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ErikEJcommented, Sep 25, 2021

Lack of rights to the Azure SQL db, known issue.

0reactions
cilerlercommented, Sep 27, 2021

bitmoji

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found