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

Occured ArgumentException about language paramter when scaffolding database #11075

Closed
jeffrey-igaw opened this issue Feb 27, 2018 · 10 comments
Closed
Assignees
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

@jeffrey-igaw
Copy link

jeffrey-igaw commented Feb 27, 2018

When i scaffolding my Efcore 2.1 project using net cli, occured Argument Exception.

Is this about .net cli version? i cannot found any parameter about language

Exception message:
image

Stack trace:

System.ArgumentNullException: Value cannot be null.
Parameter name: language
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName)
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations..ctor(IOperationReporter reporter, Assembly startupAssembly, String projectDir, String rootNamespace, String language)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.<>c__DisplayClass4_0.<.ctor>b__3()
   at Microsoft.EntityFrameworkCore.Internal.LazyRef`1.get_Value()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)

Steps to reproduce

Include a complete code listing (or project/solution) that we can run to reproduce the issue.

Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.

 dotnet ef dbcontext scaffold "Server=localhost;User Id=root;Password=123456;Database=eftests" "Microsoft.EntityFrameworkCore.SqlServer"

Further technical details

EF Core version: 2.1 preview 1 final
Database Provider: No matter
Operating system: Windows 10 Enterprise lastest release.
IDE: Rider 2017.3
.NET SDK: 2.1.3

@smitpatel
Copy link
Contributor

@jeffrey-igaw - It should automatically get the language from project file. For some reason it looks like it is not happening. As a work-around you can use --language to pass in language with C# as value.

Can you copy paste initial lines from your screen shot? Especially the line start with dotnet msbuild /target:GetEFProjectMetadata

@ajcvickers ajcvickers added this to the 2.1.0 milestone Feb 28, 2018
@bricelam
Copy link
Contributor

bricelam commented Mar 1, 2018

Did you update your <DotNetCliToolReference> to 2.1.0-preview1-final?

@jeffrey-igaw
Copy link
Author

Uhmm, you're right, i dont change that.

I will check out next working day! Thanks to your comments

@RainingNight
Copy link

I'd upgrade Microsoft.EntityFrameworkCore.Tools.DotNet to 2.1.0-preview1-final, that's worked!

@bricelam
Copy link
Contributor

bricelam commented Mar 2, 2018

🎉 Hooray! We should probably still fix the issue. There's no real reason it shouldn't work. We should also consider warning if your tool version doesn't match the runtime.

@robichaud
Copy link

robichaud commented Mar 6, 2018

I am seeing the same error when running Add-Migration from the Package Manager Console:
image

DotNetCliToolReference was updated. Here is what the csproj looks like:
image

Adding and removing migrations does work with the CLI from Command Prompt.

@RainingNight
Copy link

@robichaud Try to DotNet CLI dotnet ef migrations add xxx.

@jeffrey-igaw
Copy link
Author

@brianrob Thank you, your solution fixed it. This issue has been resolved and will be closed. :D

@ZooDoo4U
Copy link

I think there is a bug when a model includes a new field to a class, in my case a nullable field (public DateTimeOffset? DateOfInterest { get; set; }) and perform a migration. If I downgrade to 2.0.1 the migration works no error all worked fine. I then added another nullable DateTimeOffset?, upgraded back to the "2.1.0 final preview" and i get the error again...

Vitals:
VS 2017 (15.5.7)
Win 7 x64
Microsoft SQL Server Express Edition (64-bit)

Repro:
1.) Have a working application
2.) Update Microsoft.EntityFrameworkCore.Design with "2.1.0-preview1-final"
3.) Update a DB Entity with a nulable DateTimeOffest field
4.) Open package manager
5.) Add Migration
Error:
6.) Uninstall Microsoft.EntityFrameworkCore.Design
7.) Install EF Core Design "2.0.1"
8.) Add Migration
No Error...

Any additional info needed, let me know.

Hope this helps.

@ajcvickers
Copy link
Contributor

@ZooDoo4U This looks like a different problem than is being tracked here. Can you please open a new issue for it?

@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Mar 26, 2018
@ajcvickers ajcvickers modified the milestones: 2.1.0-preview2, 2.1.0 Nov 11, 2019
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

7 participants