efcore: System.MissingMethodException: Method not found: 'Void Microsoft.EntityFrameworkCore.Scaffolding.Metadata.DatabaseTable..ctor(Microsoft.EntityFrameworkCore.Scaffolding.Metadata.DatabaseModel, System.String)'.

Below is the complete stack trace of the error I receive when using following scaffold command. What could be wrong?

I am using Npgsql Postgres code, changed for my database as far as internal SQLs are concerned, as such no change in logic flow. Changed GetTables() method code is pasted below for reference, it calls “DatabaseTable()” which results into “System.MissingMethodException” exception.

…\Scaffolding\Internal\NpgsqlDatabaseModelFactory.cs

    /// <summary>
    /// Queries the database for defined tables and registers them with the model.
    /// </summary>
    static IEnumerable<DatabaseTable> GetTables(
        IfxConnection connection,
        DatabaseModel databaseModel,
        IDiagnosticsLogger<DbLoggerCategory.Scaffolding> logger)
    {
        var commandText = @"
        SELECT
           owner, tabname
        FROM
           informix.sysmaster:systables
        WHERE
           tabid > 99;";

        var tables = new List<DatabaseTable>();

        var command = new IfxCommand(commandText, connection);
        using (var reader = command.ExecuteReader())
        {
            while (reader.Read())
            {
                var schema = reader.GetValueOrDefault<string>("owner");
                var name = reader.GetString("tabname");

                var table = new DatabaseTable(databaseModel, name)
                {
                    Schema = schema,
                };

                tables.Add(table);
            }
        }

        GetColumns(connection, tables, logger);
        GetConstraints(connection, tables, out var constraintIndexes, logger);
        GetIndexes(connection, tables, constraintIndexes, logger);
        return tables;
    }

D:\shesh\EntityFrameworkCore\scaffold>dotnet ef dbcontext scaffold “Database=sheshefcoredb1; server=lo_informix1410;UID=informix; PWD=xxx” Informix.EntityFramework.Core -o Models --project MyApp.csproj -v Using project ‘MyApp.csproj’. Using startup project ‘D:\shesh\EntityFrameworkCore\scaffold\MyApp.csproj’. Writing ‘obj\MyApp.csproj.EntityFrameworkCore.targets’… dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\sheshnarayan.a\AppData\Local\Temp\tmpE5DF.tmp /verbosity:quiet /nologo MyApp.csproj Writing ‘D:\shesh\EntityFrameworkCore\scaffold\obj\MyApp.csproj.EntityFrameworkCore.targets’… dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\sheshnarayan.a\AppData\Local\Temp\tmpEA65.tmp /verbosity:quiet /nologo D:\shesh\EntityFrameworkCore\scaffold\MyApp.csproj Build started… dotnet build D:\shesh\EntityFrameworkCore\scaffold\MyApp.csproj /verbosity:quiet /nologo

Build succeeded. 0 Warning(s) 0 Error(s)

Time Elapsed 00:00:01.46 Build succeeded. dotnet exec --depsfile D:\shesh\EntityFrameworkCore\scaffold\bin\x64\Debug\netcoreapp3.1\MyApp.deps.json --additionalprobingpath C:\Users\sheshnarayan.a.nuget\packages --additionalprobingpath “C:\Program Files\dotnet\sdk\NuGetFallbackFolder” --runtimeconfig D:\shesh\EntityFrameworkCore\scaffold\bin\x64\Debug\netcoreapp3.1\MyApp.runtimeconfig.json C:\Users\sheshnarayan.a.dotnet\tools.store\dotnet-ef\3.1.5\dotnet-ef\3.1.5\tools\netcoreapp3.1\any\tools\netcoreapp2.0\any\ef.dll dbcontext scaffold “Database=sheshefcoredb1; server=lo_informix1410;UID=informix; PWD=xxx” Informix.EntityFramework.Core -o Models --assembly D:\shesh\EntityFrameworkCore\scaffold\bin\x64\Debug\netcoreapp3.1\MyApp.dll --startup-assembly D:\shesh\EntityFrameworkCore\scaffold\bin\x64\Debug\netcoreapp3.1\MyApp.dll --project-dir D:\shesh\EntityFrameworkCore\scaffold\ –language C# --working-dir D:\shesh\EntityFrameworkCore\scaffold --verbose --root-namespace MyApp Using assembly ‘MyApp’. Using startup assembly ‘MyApp’. Using application base ‘D:\shesh\EntityFrameworkCore\scaffold\bin\x64\Debug\netcoreapp3.1’. Using working directory ‘D:\shesh\EntityFrameworkCore\scaffold’. Using root namespace ‘MyApp’. Using project directory 'D:\shesh\EntityFrameworkCore\scaffold'. The EF Core tools version ‘3.1.5’ is older than that of the runtime ‘5.0.0-preview.5.20278.2’. Update the tools for the latest features and bug fixes. Finding design-time services for provider ‘Informix.EntityFramework.Core’… Using design-time services from provider ‘Informix.EntityFramework.Core’. Finding design-time services referenced by assembly ‘MyApp’. No referenced design-time services were found. Finding IDesignTimeServices implementations in assembly ‘MyApp’… No design-time services were found. System.MissingMethodException: Method not found: ‘Void Microsoft.EntityFrameworkCore.Scaffolding.Metadata.DatabaseTable…ctor(Microsoft.EntityFrameworkCore.Scaffolding.Metadata.DatabaseModel, System.String)’. at Informix.EntityFramework.Core.Scaffolding.Internal.NpgsqlDatabaseModelFactory.GetTables(IfxConnection connection, DatabaseModel databaseModel, IDiagnosticsLogger1 logger) at Informix.EntityFramework.Core.Scaffolding.Internal.NpgsqlDatabaseModelFactory.Create(DbConnection dbConnection, DatabaseModelFactoryOptions options) in D:\shesh\EntityFrameworkCore\efcore.pg-dev-ifmx-old\src\EFCore.Informix\Scaffolding\Internal\NpgsqlDatabaseModelFactory.cs:line 124 at Informix.EntityFramework.Core.Scaffolding.Internal.NpgsqlDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options) in D:\shesh\EntityFrameworkCore\efcore.pg-dev-ifmx-old\src\EFCore.Informix\Scaffolding\Internal\NpgsqlDatabaseModelFactory.cs:line 90 at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions) at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable1 schemas, IEnumerable1 tables, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable1 schemaFilters, IEnumerable1 tableFilters, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_01.<Execute>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) Method not found: ‘Void Microsoft.EntityFrameworkCore.Scaffolding.Metadata.DatabaseTable…ctor(Microsoft.EntityFrameworkCore.Scaffolding.Metadata.DatabaseModel, System.String)’.

D:\shesh\EntityFrameworkCore\scaffold>

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 39 (18 by maintainers)

Commits related to this issue

Most upvoted comments

You have mixed versions of packages.

You should never base a new provider on EF Core previews - ask me how I know 😭

I did compare with EFCore.PG, infact it uses preview-5

FYI EFCore.PG has moved forward to rc1 since you looked at it. It could be a good idea for you to do the same.

Now is a good time to switch to rc1. It’s extremely unlikely that there will be any breaking changes from now until the GA release.

@deokershesh we are currently very busy with other issues we have to give our attention to, wrapping up the EF Core 5.0 release.

Please try to compare your provider’s configuration with the working one from EFCore.PG, you should be able to spot the discrepancy yourself. Otherwise, one of us will hopefully get around to helping soon.

The file you shared does not tell what versions Informix.EntityFramework.Core brings in.