Skip to content
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

Migration fails with HasPostgresExtension. #46

Closed
sirentek opened this issue Jun 6, 2016 · 3 comments
Closed

Migration fails with HasPostgresExtension. #46

sirentek opened this issue Jun 6, 2016 · 3 comments

Comments

@sirentek
Copy link

sirentek commented Jun 6, 2016

Hi,

I decided to use Guid as primary key. Added these lines to my db context OnModelCreating:

            builder.HasPostgresExtension("uuid-ossp");

            builder.Entity<ApplicationUser>(b =>
            {
                b.Property(u => u.Id).HasDefaultValueSql("newid()");
            });

            builder.Entity<Role>(b =>
            {
                b.Property(u => u.Id).HasDefaultValueSql("newid()");
            });

SELECT UUID_GENERATE_V4() => tested and it worked via efcore 7 successfully.

Dropped my database via ef command utility.
Deleted my migration folder content in solution.

When running dotnet ef migrations add Initial, I get this exception:

System.InvalidOperationException: The current CSharpMigrationOperationGenerator cannot scaffold operations of type 'Microsoft.EntityFrameworkCore.Migrations.Ope
rations.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, IndentedStringB
uilder 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 st
artupProject, String environment, Action`1 reporter)
   at Microsoft.EntityFrameworkCore.Tools.Cli.MigrationsAddCommand.<>c__DisplayClass0_0.<Configure>b__0()
   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.NpgsqlCreatePostgresExtens
ionOperation'. Configure your services to use one that can.

I use efcore rc2 version and my nuget feedback:

    <add key="AspNetRelease" value="https://www.myget.org/F/aspnetrelease/api/v3/index.json" />
    <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
    <add key="Npgsql" value="https://www.myget.org/F/npgsql-unstable/" />

Is there anybody else having same issue ?

@roji
Copy link
Member

roji commented Jun 6, 2016

Can you please include the exact version of the Npgsql EFCore provider you're using?

@sirentek
Copy link
Author

sirentek commented Jun 6, 2016

1.Test:
Cleaned my .nuget packages folder and restored when my project.json has these

    "Npgsql.EntityFrameworkCore.PostgreSQL": "1.0.0-*",
    "Npgsql.EntityFrameworkCore.PostgreSQL.Design": "1.0.0-*",

Got the same error.

2.Test:
I cleaned my .nuget packages folder and restored when project.json has these:

    "Npgsql.EntityFrameworkCore.PostgreSQL": "1.0.0-rc2-release1",
    "Npgsql.EntityFrameworkCore.PostgreSQL.Design": "1.0.0-rc2-release1",

The error has gone 👍

@sirentek
Copy link
Author

sirentek commented Jun 6, 2016

I am closing this. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants