-
Notifications
You must be signed in to change notification settings - Fork 228
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
Enum with explicitly defined schema the same as the default schema will have its schema removed in ModelSnapshot #1657
Comments
It is possible to trick the migration class by changing the DbContext a little bit.
Note that I had to add an underscore to the enum name. The migration class will be created as it follows:
Although it works, I think it would be helpful if the framework could handle it. Also, the presented solution will not help you if your schema name contains a hyphen, as it is going to generate a SQL error when updating your database. Here is a sample project showing the problem: https://github.com/please-halp/EFCore5-Npgsql-Issue-using-enum-with-schema |
Duplicate of #2027 |
(fixed for 5.0.11) |
Using EF Core 5 and Npgsql 5, I have several enums defined, and all work as expected, except for enums explicitly set to the
public
schema (which is the default in this case).Defined as:
Within my
DbContext
I setup the enum usingI also tried setting
HasDefaultSchema('public");
but that didn't help.before running a migration,
XxDBContextModelSnapshot.cs
will have:upon creating any migration, even an empty one,
XxDBContextModelSnapshot.cs
will have the schema removed for that enum:And then if I do not keep correcting
XxDBContextModelSnapshot.cs
after any migration is generated I will have all my enums be redefined in the generated migration script. And conflicts will occur for the enum inpublic
as it already exists. Whatever writes out the changes seems to not take default schema into account, and will skip the writing if the schema set explicitly is the same as the default. This might be related to #1027 , but I am not sure.The text was updated successfully, but these errors were encountered: