Giter Site home page Giter Site logo

Comments (7)

sirentek avatar sirentek commented on July 17, 2024

Now we know the reason about this exception..
There is a missing parameter (migration executer) in constructor : Npgsql.EntityFrameworkCore.PostgreSQL/src/Npgsql.EntityFrameworkCore.PostgreSQL/Storage/Internal/NpgsqlDatabaseCreator.cs

I don't know how to solve it.. I will continue to read/understand..

from efcore.pg.

sirentek avatar sirentek commented on July 17, 2024

Hi!
@roji, I added the required parameter to the constructor. Do you think it may help ? I will compile it and test.

        public NpgsqlDatabaseCreator(
            [NotNull] NpgsqlRelationalConnection connection,
            [NotNull] IMigrationsModelDiffer modelDiffer,
            [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator,
            [NotNull] IMigrationCommandExecutor migrationCommandExecutor,
            [NotNull] IModel model,
            [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder)
            : base(model, connection, modelDiffer, migrationsSqlGenerator, migrationCommandExecutor)
        {
            Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder));

            _connection = connection;
            _migrationsSqlGenerator = migrationsSqlGenerator;
            _rawSqlCommandBuilder = rawSqlCommandBuilder;
        }

from efcore.pg.

roji avatar roji commented on July 17, 2024

@sirentek thanks for diving into this!

I looked, and it seems that the additional parameter (the IMigrationCommandExecutor) isn't present in EFCore's release branch (which is rc2), only in dev (which is rc2), the precise commit where they added it is ce07379. So a mismatch has probably occurred - you're trying to use Npgsql's EFCore provider (which is rc2) with rc3 EFCore...

I've removed Microsoft's myget aspnetcidev feed to make sure that when compiling Npgsql.EFCore there's no rc3 anywhere, but the project.json already explicitly depends on -rc2- only, so this shouldn't be happening. Take a look at exactly which dependencies are being taken when you build your application, and please let me know!

from efcore.pg.

sirentek avatar sirentek commented on July 17, 2024

You are right. The sample uses float dependencies (1.0.0-*) in project.json. As a result all packages including entity framework used rc3 versions.

In my second test, I modified the NuGet.Config file of the sample as:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="AspNetRelease" value="https://www.myget.org/F/aspnetrelease/api/v3/index.json" />

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

As you can see, I replaced the aspnetcidev with aspnetrelease. This time I didn't see any of rc3 versions during the restore.

After running dotnet ef run, it produced the following exception:

System.MissingMethodException: Method not found: 'Void Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator..ctor(Microsoft.EntityFrameworkCore.Metad
ata.IModel, Microsoft.EntityFrameworkCore.Storage.IRelationalConnection, Microsoft.EntityFrameworkCore.Migrations.IMigrationsModelDiffer, Microsoft.EntityFramew
orkCore.Migrations.IMigrationsSqlGenerator)'.
   at Microsoft.EntityFrameworkCore.Storage.Internal.NpgsqlDatabaseCreator..ctor(NpgsqlRelationalConnection connection, IMigrationsModelDiffer modelDiffer, IMig
rationsSqlGenerator migrationsSqlGenerator, IModel model, IRawSqlCommandBuilder rawSqlCommandBuilder)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.TransientCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.TransientCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService[T](IServiceProvider provider)
   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)

It seems, it is not an easy task for me to fix the constructor parameters. It ends up with dependency problems (rc2->rc3).

from efcore.pg.

roji avatar roji commented on July 17, 2024

Am not 100% sure about this, but I think you may still be using rc3 packages cached inside .nuget in your home directory... Can you try specifying rc2 explicitly in your project.json? Another option is deleting your .nuget dir and restoring again after having changed your NuGet.Config.

from efcore.pg.

sirentek avatar sirentek commented on July 17, 2024

Replaced all version names with explicit rc2 ones (1.0.0-rc2-*) in project.json.
Deleted all packages under home .nuget directory (more than 12GB).
Restored again (still using aspnetrelease feed in Nuget.Config.)
Error :
Unable to resolve 'Microsoft.EntityFrameworkCore.Tools (>= 1.0.0-rc2-3002543)' for '.NETCoreApp,Version=v1.0'.

I uninstalled my dotnet/cli (it was 1.0.0.2543) and installed the latest one (1.0.0.2697).
Again deleted all the packages under home .nuget directory.
Restored with success.

Migration files were created without any problem.
I login as admin and edit the records from the sample. It works like a charm!

Thanks @roji ! I am closing this issue.

from efcore.pg.

roji avatar roji commented on July 17, 2024

Ah, the pleasures of fighting with Microsoft prerelease software :)

Glad it worked out.

from efcore.pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.