-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Make Scaffold generate field as CLR Enum #27792
Comments
This is possible semi-automatic with EF Core Power Tools |
Note that in the PostgreSQL context above we have native enum types in the database itself, which can be mapped to CLR enums (see the npgsql docs). I'm not sure if there's a place where user code could be placed for execution before reverse engineering takes place - if so, doing Otherwise, in the more general context, this could probably be achieved by customizing templates, which is being done for EF Core 7.0 (see #4038). |
Thank you for your advices. I was thinking about using either native Postgresql enums and current int fields. But in the case with using int type I admitted to add Item.Status field manually in a partial class, but I didn't find a way to exclude fields (not whole tables) from generating by Scaffold. Is there a way to exclude field from Scaffold? |
Yes excluding columns is possible with EF Core Power Tools. |
Thank you all. I will use EF Core Power Tools |
Is it possible to achieve this using CLI? |
@rmcp Yes, if you combine with .t4 templates. |
Hello!
I use ef core database-first approach in my project, and I have a table that is described with the class
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
The text was updated successfully, but these errors were encountered: