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
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.
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)`
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)
Closing, but feel free to reply if the above comment does not resolve your issue and we will reopen.
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%" ]
}
}
`
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.
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.
cc @SapientGuardian
We will revert this breaking change, even though it is on an internal type.
@jeffbromberger this means the SapientGuardian provider should work with the RTM of 1.1.0
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
@SapientGuardian Could you let us know which internal APIs you are using? Last time I checked, npgsql was only using the following:
/cc @roji
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.
We're currently using the following internals:
And here are our source files that reference them:
@SapientGuardian How is MySQLCommandBatchPreparer used? (Which uses MySQLValueBufferFactoryFactory.) It seems like this is dead code unless I am missing something.
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?
@SapientGuardian Indeed it's dead code, it can be removed.
Excellent. I've removed the dead code from our repo, and updated my post above.
@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).
@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.
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 5e1c562ae40c16ef49b90731fd015eccce0c1d44.
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.
Decided to instead open an new issue (#6926) and keep this one closed.
@ajcvickers will hunt and try to remove Internal usage on my side (https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/122).
FYI RelationalModelValidator is not longer used in my 1.1.0 branch.
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.
Most helpful comment
You are referencing 1.0.1 of Microsoft.EntityFrameworkCore.Design:
This package needs to match the version of the runtime you are using (1.1.0-preview1-final)