Make Scaffold generate field as CLR Enum
See original GitHub issueHello! I use ef core database-first approach in my project, and I have a table that is described with the class
public class Item
{
public int Id { get; set; }
public string Name { get; set; }
public int Status { get; set; }
}
public enum Status
{
New = 1,
InProgress = 2,
Complete = 3
}
I want Scaffold to make Item.Status property as Status type. Is it possible to point out to use a pre-defined enum for some fields when using Scaffold?
I found a post on SO (https://stackoverflow.com/questions/44262314/how-can-i-make-ef-core-database-first-use-enums), but the answer is for code-first approach
EF Core version: 6.0.3 Database provider: Npgsql.EntityFrameworkCore.PostgreSQL Target framework: . .NET 6.0 Operating system: Windows 11 IDE: Visual Studio 2022 17.1.1
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Entity framework Core - Scaffolding enum
Context: I use Database-first approach to generate my entities with Entity Framework Core and with use of Scaffolding. · Problem: I would like...
Read more >Enum Type Mapping
You will have to create the CLR type, add the global mapping and add the properties to your entities. In the future it...
Read more >How to use Enums when using Entity Framework Core with ...
Our first option was to model the enum as a separate table and use an unmapped property to cast it to an enum,...
Read more >Value Conversions - EF Core
Configuring value converters in an Entity Framework Core model.
Read more >Entity Framework Core: Enums
Enum support in EF Core is quite extensive, in this article I'll cover how to use an enum as a Primary Key, as...
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
@rmcp Yes, if you combine with .t4 templates.
Is it possible to achieve this using CLI?