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

Method not found: 'System.String Microsoft.EntityFrameworkCore.Metadata.Internal.EntityTypeExtensions.DisplayName(Microsoft.EntityFrameworkCore.Metadata.IEntityType)'. #6914

Closed
lee-alderdice opened this issue Nov 1, 2016 · 22 comments
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@lee-alderdice
Copy link

lee-alderdice commented Nov 1, 2016

Hi. I have read #6865, #6855, and https://blogs.msdn.microsoft.com/dotnet/2016/10/25/announcing-entity-framework-core-1-1-preview-1/ from the release.

I am trying to run Scaffold-DbContext "Server=(A);Database=B;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Verbose

I am getting the error Method Not Found as per the title (full error at the bottom). To try and resolve this I have

  • updated the listed packages as detailed in the release blog.
  • Kept using netcore 1.0.0
  • run dotnet restore (many times)
  • restarted VS and my machine (many times)

I have read that I may need to delete the Entity Framework directory under %USERPROFILE%/.nuget ... but that seems a bit drastic.

Below is my project.json ... I think I a missing something small and would appreciate any pointers to help through this. I did try rolling back to preview2-final on tools but it all seems to have gone a bit wrong.

`{
"dependencies": {
"Microsoft.AspNetCore.Authentication": "1.0.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Authorization": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Identity": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.Session": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.Design": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0-preview1-final",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0-preview1-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.1.0-preview1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
}
},

"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},

"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},

"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},

"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},

"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},

"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
`
and here is the full error message ...

System.MissingMethodException: Method not found: 'System.String Microsoft.EntityFrameworkCore.Metadata.Internal.EntityTypeExtensions.DisplayName(Microsoft.EntityFrameworkCore.Metadata.IEntityType)'. at Microsoft.EntityFrameworkCore.Scaffolding.Internal.StringBuilderCodeWriter.WriteCodeAsync(ModelConfiguration modelConfiguration, String outputPath, String dbContextClassName, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineeringGenerator.GenerateAsync(ReverseEngineeringConfiguration configuration, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContextAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable1 schemas, IEnumerable1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.<ScaffoldContextImpl>d__22.MoveNext() at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 source, Int32& length)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 source) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass4_01.b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)`

@rowanmiller
Copy link
Contributor

You are referencing 1.0.1 of Microsoft.EntityFrameworkCore.Design:

"Microsoft.EntityFrameworkCore.Design": "1.0.1",

This package needs to match the version of the runtime you are using (1.1.0-preview1-final)

@rowanmiller
Copy link
Contributor

Closing, but feel free to reply if the above comment does not resolve your issue and we will reopen.

@rowanmiller rowanmiller added the closed-no-further-action The issue is closed and no further action is planned. label Nov 1, 2016
@jeffbromberger
Copy link

I didn't want to open another issue since my description is the same as this one. I just updated to 1.1 and I'm getting an exception on any db access. I'm using the SapientGuardian provider but I'm not sure if this is an issue with EF or with the provider. The exception I get is:

"Method not found: 'System.String Microsoft.EntityFrameworkCore.Metadata.Internal.EntityTypeExtensions.DisplayName(Microsoft.EntityFrameworkCore.Metadata.IEntityType)'."

This occurs doing a simple lookup like this:

var agency = databaseStore.Agencies.FirstOrDefault<Agency>(a => a.Id == agencyId);

Here is my project.json file.

`{
"dependencies": {
"AWSSDK.CognitoIdentity": "3.3.0.1",
"AWSSDK.CognitoIdentityProvider": "3.3.1.1",
"AWSSDK.Core": "3.3.3",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0-preview1-final",
"Microsoft.EntityFrameworkCore": "1.1.0-preview1-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview3-final",
"Microsoft.Extensions.Caching.Memory": "1.1.0-preview1-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-preview1-final",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0-preview1-final",
"Microsoft.Extensions.Configuration.Json": "1.1.0-preview1-final",
"Microsoft.Extensions.Logging": "1.1.0-preview1-final",
"Microsoft.Extensions.Logging.Console": "1.1.0-preview1-final",
"Microsoft.Extensions.Logging.Debug": "1.1.0-preview1-final",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0-preview1-final",
"Microsoft.NETCore.App": "1.1.0-preview1-001100-00",
"SapientGuardian.EntityFrameworkCore.MySql": "7.1.10",
"System.IdentityModel.Tokens.Jwt": "5.0.1-pre-310121323",
"Microsoft.AspNetCore.Authentication": "1.1.0-preview1-final",
"Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0-preview1-final",
"Microsoft.AspNetCore.Cors": "1.1.0-preview1-final",
"Microsoft.AspNetCore.Mvc": "1.1.0-preview1-final",
"Microsoft.AspNetCore.Hosting": "1.1.0-preview1-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-preview1-final",
"Microsoft.AspNetCore.Diagnostics": "1.1.0-preview1-final"
},

"tools": {
},

"frameworks": {
    "netcoreapp1.0": {
        "imports": [
            "dotnet5.6",
            "portable-net45+win8"
        ]
    }
},

"runtimes": {
    "win10-x64": { }
},

"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},

"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},

"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},

"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
`

@rowanmiller
Copy link
Contributor

Sounds like the provider needs to recompile on 1.1. We tested the most common providers to ensure compatibility with 1.1 (Npgsql, SQL Server, SQLite, and MySQL) but we didn't test every provider.

Reopening to discuss in triage if this is a change we want to roll back or not.

@rowanmiller rowanmiller reopened this Nov 2, 2016
@rowanmiller rowanmiller removed the closed-no-further-action The issue is closed and no further action is planned. label Nov 2, 2016
@jeffbromberger
Copy link

jeffbromberger commented Nov 2, 2016

Thank you for replying/reopening. For what it is worth, I tried to use the official MySQL provider originally but couldn't even get started. It seems as though their provider does not currently implement the functions necessary to allow the code-first migration functionality to work (running the migration script fails). Bug here: http://bugs.mysql.com/bug.php?id=82981

That is what led me to SapientGuardian to at least get something working. Honestly I would be happy to use anything that works at this point. For now I have reverted back to EF 1.0.1 so I can continue my dev, but I'd love to try 1.1 when there is some movement on this issue.

@rowanmiller
Copy link
Contributor

cc @SapientGuardian

@rowanmiller rowanmiller added this to the 1.1.0 milestone Nov 2, 2016
@rowanmiller
Copy link
Contributor

We will revert this breaking change, even though it is on an internal type.

@rowanmiller
Copy link
Contributor

@jeffbromberger this means the SapientGuardian provider should work with the RTM of 1.1.0

ajcvickers added a commit that referenced this issue Nov 2, 2016
Issue #6914

Method is not an extension method and is obsolete but should allow code already bound it to continue working.
@SapientGuardian
Copy link

Thanks for the heads up. Is it practical to build an EF provider that doesn't rely on the internal namespaces at this point? It looks like the Npgsql provider references them too, though perhaps not the parts that triggered this break. Rebuilding against new libraries is easy enough, but eliminating the references to the internals seems like a fair bit of work.

cc @how02

@ajcvickers
Copy link
Member

@SapientGuardian Could you let us know which internal APIs you are using? Last time I checked, npgsql was only using the following:

  • RelationalFullAnnotationNames
  • RelationalModelValidator
  • RelationalConventionSetBuilder
  • RelationalStrings.UpdateConcurrencyException, UpdateStoreException
  • IInternalDatabaseModelFactory

/cc @roji

@rowanmiller
Copy link
Contributor

BTW our goal is that folks don't have to use internals... but that isn't reality yet. If a provider needs an API, our goal is to tidy it up and make it public.

@SapientGuardian
Copy link

SapientGuardian commented Nov 2, 2016

We're currently using the following internals:

  • Microsoft.EntityFrameworkCore.Update.Internal.IKeyValueIndexFactorySource
  • Microsoft.EntityFrameworkCore.Update.Internal.CommandBatchPreparer
  • Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ICoreConventionSetBuilder
  • Microsoft.EntityFrameworkCore.Metadata.Internal.RelationalFullAnnotationNames
  • Microsoft.EntityFrameworkCore.Internal.RelationalStrings.UnsupportedType(...)
  • Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.IConventionSetBuilder
  • Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal.{ContainsTranslator, EndsWithTranslator, EqualsTranslator, IsNullOrEmptyTranslator, StartsWithTranslator}

And here are our source files that reference them:

@ajcvickers
Copy link
Member

@SapientGuardian How is MySQLCommandBatchPreparer used? (Which uses MySQLValueBufferFactoryFactory.) It seems like this is dead code unless I am missing something.

@SapientGuardian
Copy link

I was wondering that myself. I thought it might be something pulled in externally by convention/reflection/magic, but it might just be dead. @how02 that code came in on one of your commits, can you solve the mystery?

@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Nov 3, 2016
@how02
Copy link

how02 commented Nov 3, 2016

@SapientGuardian Indeed it's dead code, it can be removed.

@SapientGuardian
Copy link

Excellent. I've removed the dead code from our repo, and updated my post above.

@divega
Copy link
Contributor

divega commented Nov 3, 2016

@ajcvickers aren't there any more reversions we want to want to do in 1.1? (not sure if this was closed automatically when you pushed your change).

@ajcvickers
Copy link
Member

@divega I made a reference to this discussion in #6716. We decided not to make changes just because providers use internal code. We also did verification with a set of providers that was agreed upon. If we want to do additional checks to see if this or other providers are broken, then that should probably be a new issue that we discuss in triage.

@divega
Copy link
Contributor

divega commented Nov 3, 2016

Here is some additional information from pushing the SapientGuardian provider through NGen (similar to #6783):

Warning: System.MissingMethodException: Method not found: 'Void Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal.ContainsTranslator..ctor()'. while resolving 0xa000023 - Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal.ContainsTranslator..ctor.
Warning: System.MissingMethodException: Method not found: 'Void Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal.EndsWithTranslator..ctor()'. while resolving 0xa000037 - Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal.EndsWithTranslator..ctor.
Warning: System.MissingMethodException: Method not found: 'Void Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal.StartsWithTranslator..ctor()'. while resolving 0xa00003a - Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal.StartsWithTranslator..ctor.
Method not found: 'Void Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal.ContainsTranslator..ctor()'. while compiling method MySqlContainsTranslator..ctor
Method not found: 'Void Microsoft.EntityFrameworkCore.Query.ExpressionTranslators.Internal.EndsWithTranslator..ctor()'. while compiling method MySQLCompositeMethodCallTranslator..ctor

The cause is that we removed the parameterless constructors from string method translators in 5e1c562.

Reactivating so that we can decide in triage whether we want to fix this for the same reason we reverted the removal of EntityTypeExtensions.DisplayName() or whether we want to treat this with the default bar for internal types.

@divega divega reopened this Nov 3, 2016
@divega divega removed this from the 1.1.0 milestone Nov 3, 2016
@divega divega removed the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Nov 3, 2016
@divega
Copy link
Contributor

divega commented Nov 3, 2016

Decided to instead open an new issue (#6926) and keep this one closed.

@divega divega closed this as completed Nov 3, 2016
@divega divega added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Nov 3, 2016
@divega divega added this to the 1.1.0 milestone Nov 3, 2016
@roji
Copy link
Member

roji commented Nov 3, 2016

@ajcvickers will hunt and try to remove Internal usage on my side (npgsql/efcore.pg#122).

FYI RelationalModelValidator is not longer used in my 1.1.0 branch.

smitpatel pushed a commit that referenced this issue Nov 8, 2016
Issue #6914

Method is not an extension method and is obsolete but should allow code already bound it to continue working.
@phil-debbs
Copy link

You are referencing 1.0.1 of Microsoft.EntityFrameworkCore.Design:

"Microsoft.EntityFrameworkCore.Design": "1.0.1",

This package needs to match the version of the runtime you are using (1.1.0-preview1-final)

Thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

9 participants