-
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
Map enum to string set default enum value via HasDefaultValueSql #19843
Comments
@wangpengxpy |
@ajcvickers thanks your reply |
@wangpengxpy Thanks for the additional info. Team: I can reproduce the issue with
|
@ajcvickers,thanks for reopening,I hope this problem can be improved |
@wangpengxpy The team pointed out to me that my suggestion to use |
@ajcvickers @tonysneed what about when you use scaffolding with a db first scenario, and use handlebars to set an entity's property to an enum? EF scaffolding automatically applies the |
@johnwc That would be a Handlebars issue |
@ErikEJ How so? The error is occurring so early, I cannot overwrite the default value within the |
@johnwc Maybe you should consider T4 templates? |
@ErikEJ do you have an example repo I can check out T4 templates with ef core scaffolding? What is the purpose of |
I have some samples here: ErikEJ/EFCorePowerTools#1499 |
First,mapping enum to tinyint is fine,code show as below
but map to string can not work,code show as below
The follow exception:
Microsoft.Data.SqlClient.SqlException: "The name" Black "is not allowed in this context. Valid expressions include constants, constant expressions, and variables (in some contexts). Column names are not allowed.
More details:
EF Core version: 3.1.1
Database provider: (Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (.NET Core 3.1)
Operating system: Windows 10
IDE: (Visual Studio 2019 16.4.4)
The text was updated successfully, but these errors were encountered: