Hi,
I upgraded to latest version 2.1.0-*. After upgrade the project is not building. It is failing in compilation of migration files:
Migrations/ApplicationDbContextModelSnapshot.cs(21,66): error CS0103: The name 'NpgsqlValueGenerationStrategy' does not exist in the current context
This is a result of #339. I'll fix this for rc1.
After thinking about this some more, it seems reasonable to request developers to introduce a missing using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata into their migration files and model snapshot. This isn't ideal in a minor version release, but it does allow for cleaner and safer namespace separation.
If anyone thinks this is too much let me know.
@roji Migration files are autogenerated, updating autogenerated files doesn't seem like a good idea
@adnan-kamili migration files are only generated once (when you do dotnet ef migrations add), and aren't updated again. And when you use 2.1 to generate new migrations (or regenerate the model snapshot), it will correctly include the using statement; the issue is only with files which were generated before the upgrade to 2.1.
Besides, it's perfectly fine to manually edit your migration files - this is something that EF Core recommends that you do if needed, and is necessary in many cases, like for adding raw SQL statements for features which it doesn't manage.
I agree it isn't ideal to ask people to change code that's already been generated, but I'd prefer keeping things clean and this seems like a very small and very low-risk thing.
@roji I thought we would have to do it always, it's completely fine doing it for existing files. I suppose then I can upgrade to 2.1.0-* just by adding
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
to the migration files
@roji I thought we would have to do it always, it's completely fine doing it for existing files
Right - the issue is only with migration that have already been generated pre-2.1. Try upgrading to 2.1.0-*, adding the missing using and then creating a new migration just to make sure everything works well (and let me know if you encounter any issues!)
Most helpful comment
After thinking about this some more, it seems reasonable to request developers to introduce a missing
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadatainto their migration files and model snapshot. This isn't ideal in a minor version release, but it does allow for cleaner and safer namespace separation.If anyone thinks this is too much let me know.