efcore.pg: Migration fails with HasPostgresExtension
possibly related to #46 and the 1.0.0 release. but
System.InvalidOperationException: The current CSharpMigrationOperationGenerator cannot scaffold operations of type 'Microsoft.EntityFrameworkCore.Migrations.Operations.NpgsqlCreatePostgresExtensionOperation'. Configure your services to use one that can.
at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(MigrationOperation operation, IndentedStringBuilder builder)
at CallSite.Target(Closure , CallSite , CSharpMigrationOperationGenerator , Object , IndentedStringBuilder )
at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(String builderName, IReadOnlyList`1 operations, IndentedStringBuilder builder)
at Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGenerator.GenerateMigration(String migrationNamespace, String migrationName, IReadOnlyList`1 upOperations, IReadOnlyList`1 downOperations)
at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(String migrationName, String rootNamespace, String subNamespace)
at Microsoft.EntityFrameworkCore.Design.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Tools.Cli.MigrationsAddCommand.Execute(CommonOptions commonOptions, String name, String outputDir, String context, String environment, Action`1 reporter)
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Cli.Program.Main(String[] args)
The current CSharpMigrationOperationGenerator cannot scaffold operations of type 'Microsoft.EntityFrameworkCore.Migrations.Operations.NpgsqlCreatePostgresExtensionOperation'. Configure your services to use one that can.
caused by:
protected override void OnModelCreating(ModelBuilder builder)
{
builder.HasPostgresExtension("uuid-ossp");
base.OnModelCreating(builder);
}
the author in #46 said they cleared up this issue by cleaning nuget packages and restoring again, but this has not helped.
Thanks!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 46 (20 by maintainers)
Commits related to this issue
- Properly support PG extensions in migrations Migrations can now contain CreatePostgresExtension() and DropPostgresExtension(). Fixes #58 (cherry picked from commit 57a5054a3d7d293f33733596d7882035b... — committed to npgsql/efcore.pg by roji 8 years ago
- Properly support PG extensions in migrations Migrations can now contain CreatePostgresExtension() and DropPostgresExtension(). Fixes #58 (cherry picked from commit 8f2267b91c21ed1fa5f4924fd08138ccb... — committed to npgsql/efcore.pg by roji 8 years ago
- Properly support PG extensions in migrations Migrations can now contain CreatePostgresExtension() and DropPostgresExtension(). Fixes #58 — committed to npgsql/efcore.pg by roji 8 years ago
I’ll look into this asap and release a 1.0.2 if necessary
I’ll release 1.0.1 in a day or two… hang in there
Is there any workaround for now? This is blocker for me. I need to use
modelBuilder.HasPostgresExtension("uuid-ossp");to generate migration, but when adding this it’s still failed withNot really… But will do my best to at least make CI packages available.
I just upgraded to 1.0.1 but i’m still getting this error:
This is happening executing command in package manager console:
@allangomessl, 1.0.0-release-1 would be a prerelease, not a stable release which is what we want (read about semver and nuget versioning). I’ll try to get 1.0.1 out the door soon.
@roji Thanks. Adding Npgsql.EntityFrameworkCore.PostgreSQL.Design 1.0.1 to
package.jsonfile has fixed the issue, too.Thanks @roji.
Was getting error even after upgrade to 1.0.1.
Got it fixed by adding Npgsql.EntityFrameworkCore.PostgreSQL.Design.
@bsheldrick, @ivankarpey, I can’t see the error happening…
I have a test project with a dependency on Npgsql.EFCore.PostgreSQL 1.0.0 that has
builder.HasPostgresExtension("uuid-ossp")in the context. Doingdotnet ef migrations add initialfails as expected. Once I change the dependency to 1.0.1 (and dodotnet restore), running the same command succeeds…Can you please double-check your project.json and make sure you ran
dotnet restore? If you’re still getting the issue please try posting a link to a sample project which shows the issue.As well upgraded to 1.0.1 and command
dotnet ef migrations add Initialthrow exception, which is the same as for @bsheldrick