Efcore: Scaffold error "Value cannot be null. (Parameter 'args')"

Created on 14 Aug 2020  路  22Comments  路  Source: dotnet/efcore

I am using command, "dotnet ef dbcontext scaffold "Database=sheshefcoredb1; server=lo_informix1410;UID=informix; PWD=IFMX4xxxx" Informix.EntityFramework.Core -o Models --project MyApp.csproj" to create models from tables of database sheshefcoredb1. However it reports error "Value cannot be null. (Parameter 'args')", what am I missing? Below is stack trace, I tried to debug the "dotnet" by passing the argument "ef dbcontext scaffold "Database=sheshefcoredb1; server=lo_informix1410;UID=informix; PWD=IFMX4xxxx" Informix.EntityFramework.Core -o Models --project MyApp.csproj" and putting breakpoints in the file mentioned in the below stack, however the debugger doesn't stop in any of the files/lines mentioned! Any help is highly appreciated.

D:\shesh\EntityFrameworkCore\scaffold>dotnet ef dbcontext scaffold "Database=sheshefcoredb1; server=lo_informix1410;UID=informix; PWD=IFMX4xxxx" Informix.EntityFramework.Core -o Models --project MyApp.csproj
Build started...
Build succeeded.
System.ArgumentNullException: Value cannot be null. (Parameter 'args')
at Microsoft.EntityFrameworkCore.Utilities.Check.NotNullT in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\Shared\Check.cs:line 28
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations..ctor(IOperationReporter reporter, Assembly assembly, Assembly startupAssembly, String projectDir, String rootNamespace, String language, String[] args) in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\Internal\DatabaseOperations.cs:line 49
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.get_DatabaseOperations() in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 123
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) in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 502
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0() in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 476
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.b__0() in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 617
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 600
Value cannot be null. (Parameter 'args')

D:\shesh\EntityFrameworkCore\scaffold>

closed-question customer-reported

Most helpful comment

@ErikEJ - Because their client (equivalent of SqlClient) is .NET Core only.

@deokershesh - As previously mentioned few times in this thread.

  • If you are trying to build provider by forking efcore repo, it will never reach completion. 3rd party EF Core providers need to consume Microsoft.EntityFrameworkCore* packages through nuget and not via direct source. Otherwise you will run in all sorts of assembly mismatch issues. Even if you get all your tests to pass in your provider tests, no one else can use the package.
  • If your provider is special that it needs to use .netcoreapp only, then forking even 3rd party provider would be painful too. Each provider is customized for it's own needs and yours are different than what is out there. (Like you trying to build npgsql provider has 0 value. Neither you should be building it, nor filing for issues when it does not build).
  • Unless you are experienced with all the intricacies around structure of efcore (or even efcore.pg) repo for build related tasks, my advise is not get bogged with all that. That is the issue you are seeing while building efcore.pg right now.

Just create a .netcore class library which references your informix ADO.NET provider (through source project or nuget package is your choice) & Microsoft.EntityFrameworkCore.Relational package from nuget (this must be nuget package reference). And try writing tests against it. You can look into SqlServer provider source code for understanding of what needs to be implemented in your provider. Error messages in your tests would tell you what is not implemented in your provider and give you direction.

If you are not doing in above way then you are going to run into issue and it is not recommended way from us and I feel that it would be waste of resources for us trying to solve your issues of doing things wrong way which can be better used in fixing real bugs people have with EF Core as product.

All 22 comments

Duplicate of #20741

You need to upgrade EF Core runtime version to get the fix or upgrade the tools to match with runtime.

Thanks smitpatel, Currently dotnet sdk version I am using is 3.1.107, as per the issue #20741, upgrading the dotnet SDK version to 3.1.3 should fix the issue? Is that correct?

I downloaded v3.1.401 "dotnet-sdk-3.1.401-win-x64.exe", hope this will also have the fixes since its later version of the fixed version. Please confirm. Thanks in advance.

I upgraded to .NET Core SDK v3.1.401 but still getting the same problem!!

D:\shesh\EntityFrameworkCore\scaffold>dotnet ef dbcontext scaffold "Database=sheshefcoredb1; server=lo_informix1410;UID=informix; PWD=IFMX4xxxx" Informix.EntityFramework.Core -o Models --project MyApp.csproj

Welcome to .NET Core 3.1!

SDK Version: 3.1.401

Telemetry

The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry


Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs

Write your first app: https://aka.ms/first-net-core-app

Build started...
Build succeeded.
System.ArgumentNullException: Value cannot be null. (Parameter 'args')
at Microsoft.EntityFrameworkCore.Utilities.Check.NotNullT in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\Shared\Check.cs:line 28
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations..ctor(IOperationReporter reporter, Assembly assembly, Assembly startupAssembly, String projectDir, String rootNamespace, String language, String[] args) in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\Internal\DatabaseOperations.cs:line 49
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.get_DatabaseOperations() in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 123
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) in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 502
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0() in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 476
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.b__0() in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 617
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 600
Value cannot be null. (Parameter 'args')

D:\shesh\EntityFrameworkCore\scaffold>

You are using dotnet-ef version 3.1.x and Microsoft.EntityFrameworkCore package 5.0-*. They can work but it will run into issue as above. Either upgrade Microsoft.EntityFrameworkCore (and any other EFCore related packages) to 5.0 preview7 or upgrade the dotnet-ef tools to match with EF Core packages you are referencing.

@smitpatel,

I installed "5.0.100-preview.7.20366.6" version. I tried to build the "EF Core provider" (cloned from repository https://github.com/dotnet/efcore and made appropriate changes for Informix), with this(5.0.100-preview.7.20366.6) version of dotnet runtime/sdk and facing below compile issue. Attaching the "global.json" (with .txt extension) file as well.

However the same "EF Core Provider" code, I was able to build successfully using dotnet version "5.0.100-preview.2.20176.6". Now, even before I get to the "scaffold" issue, I need to resolve the "EF Core Provider" failure. Please could you help me to point out, what am I missing?

D:\shesh\EntityFrameworkCore\efcore-master-Informix>dotnet --version
5.0.100-preview.7.20366.6

D:\shesh\EntityFrameworkCore\efcore-master-Informix>dotnet-ef --version
Entity Framework Core .NET Command-line Tools
3.1.5

D:\shesh\EntityFrameworkCore\efcore-master-Informix>build
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-preview.7.20366.6/dotnet-sdk-5.0.100-preview.7.20366.6-win-x64.zip
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-preview.7.20366.6/dotnet-sdk-5.0.100-preview.7.20366.6-win-x64.zip
dotnet-install: Adding to current process PATH: "D:\shesh\EntityFrameworkCore\efcore-master-Informix.dotnet\". Note: This change will not be visible if PowerShell was run as a child process.
dotnet-install: Installation finished

Welcome to .NET 5.0!

SDK Version: 5.0.100-preview.7.20366.6

Telemetry

The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry


Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).

Learn about HTTPS: https://aka.ms/dotnet-https

Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core

Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli

Determining projects to restore...
All projects are up-to-date for restore.
dotnet-install: .NET Core Runtime version 3.1.6 is already installed.
dotnet-install: ASP.NET Core Runtime version 3.1.6 is already installed.

C:\Users\sheshnarayan.a.nuget\packages\microsoft.build.tasks.git\1.1.0-beta-20206-02\build\Microsoft.Build.Tasks.Git.targets(24,5): error : Unable to locate repository with working directory that contains directory 'D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\ef'. [D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\ef\ef.csproj]
C:\Users\sheshnarayan.a.nuget\packages\microsoft.build.tasks.git\1.1.0-beta-20206-02\build\Microsoft.Build.Tasks.Git.targets(47,5): error : Unable to locate repository with working directory that contains directory 'D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\ef'. [D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\ef\ef.csproj]
C:\Users\sheshnarayan.a.nuget\packages\microsoft.build.tasks.git\1.1.0-beta-20206-02\build\Microsoft.Build.Tasks.Git.targets(24,5): error : Unable to locate repository with working directory that contains directory 'D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\ef'. [D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\ef\ef.csproj]
C:\Users\sheshnarayan.a.nuget\packages\microsoft.build.tasks.git\1.1.0-beta-20206-02\build\Microsoft.Build.Tasks.Git.targets(47,5): error : Unable to locate repository with working directory that contains directory 'D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\ef'. [D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\ef\ef.csproj]
...
...

global.json.txt

"EF Core Provider" build is working now, I ignored the above errors, as its not impacting my EF Core Provider tests. I could connect to Informix database and do all CRUD operation. However "scaffold" still reports same error (issue #20741) inspite of upgrading to version "5.0.100-preview.7.20366.6". What am I missing?

D:\shesh\EntityFrameworkCore\scaffold>dotnet --version
5.0.100-preview.7.20366.6

D:\shesh\EntityFrameworkCore\scaffold>dotnet ef dbcontext scaffold "Database=sheshefcoredb1; server=lo_informix1410;UID=informix; PWD=IFMX4xxxx" Informix.EntityFramework.Core -o Models --project MyApp.csproj
Build started...
Build succeeded.
System.ArgumentNullException: Value cannot be null. (Parameter 'args')
at Microsoft.EntityFrameworkCore.Utilities.Check.NotNullT in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\Shared\Check.cs:line 28
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations..ctor(IOperationReporter reporter, Assembly assembly, Assembly startupAssembly, String projectDir, String rootNamespace, String language, String[] args) in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\Internal\DatabaseOperations.cs:line 49
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.get_DatabaseOperations() in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 123
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) in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 502
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0() in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 476
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.b__0() in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 617
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) in D:\shesh\EntityFrameworkCore\efcore-master-Informix\src\EFCore.Design\Design\OperationExecutor.cs:line 600
Value cannot be null. (Parameter 'args')

D:\shesh\EntityFrameworkCore\scaffold>

Any hint/pointer please?

@deokershesh Unfortunately, we don't have the bandwidth to work through general build issues with you. Also, in general, we don't have the bandwidth to figure out what you are doing in your environment when building your provider. As has been suggested in the past, please structure your provide projects in the same way the Pomelo MySQL or Npgsql EF Core providers do. This should ensure that you're using appropriate dependencies for development such that you won't keep running into these issues.

Also, when seeing issues with your provider please make sure that they can also be reproduced with another provider (e.g. SQL Server) before filing. If it turns out that the issue only reproduces with your provider, then we will try to help, but we do expect some analysis beforehand of what it is that makes your provider different.

@ajcvickers, Thanks for response. I was particularly trying to get help for the old issue #20741, where it mentioned upgrading to v5 review7 should fix the issue. I did upgrade to v5 review7, rebuild my EF Core Provider (forked few months ago and changed code to suit Informix support), however inspite of upgrading, problem still continues. Hence looking for suggestions.

By the way, do we have any program which takes care of evangelizing EF Core Provider to support databases which is away from it?

D:\shesh\EntityFrameworkCore\Test_Projects_Informix>dotnet --version
5.0.100-preview.7.20366.6

D:\shesh\EntityFrameworkCore\Test_Projects_Informix>

@deokershesh I don't want to seem rude, but to be absolutely clear, if you're forking the efcore repo to create a provider, then you're doing it wrong.

@ajcvickers, Thanks for your candid feedback. I did try with the mentioned repositories and faced many problems and was not able to proceed at all. Then, I forked efcore and was able to make significant progress, and today it works to great extent. Now, I am trying to make other functionalities like scaffolding/migrations etc work. In the efcore repository, primarily I am making changes in EFCore.SqlServer and EFCore.Relational folders. I believe, Pomelo MySQL and Npgsql EF Core providers also originally picked "efcore" repository. If you would still recommend Pomelo MySQL or Npgsql EF Core providers repository I will certainly try one more time.

@deokershesh as a provider writer, I can only agree with @ajcvickers

The way to write a provider is to consume the EF Core Relational package.

This is exactly what I did in the two providers I wrote.

You cannot make changes to EF Core Relational if you actually want to ship your provider, but due to the extensible architecture of EF Core, anything you need to do differently from EF Core Relational can be replaced/overridden.

I addition, consume the specification test packages, and inherit them all.

Thanks @ErikEJ for your inputs. I will retry NPGSQL PostgresSQL provider code, however looking at code structure, I may continue to hit the above problem! but we will see when I get there! Is there any documentation you have which you can share about how to write new EF Core provider? Is there any other Microsoft .NET Core Support available that we could get, like if needed to get into the call or like directly reach out to get help?

Is there any good set of documentation available which possibly helps to write first time EF Core Provider and its mandated set of APIs to be supported? I am trying to follow below links, which seems to be almost 4 years old and seems to be referencing old provider version. Is there any newer one available OR old one still valid for most part?

https://docs.microsoft.com/en-us/ef/core/providers/writing-a-provider
https://blog.oneunicorn.com/2016/11/11/so-you-want-to-write-an-ef-core-provider/

In addition to the resources listed, you can follow the commit series in this repo: https://github.com/GibraltarSoftware/VistaDB.EFCore/commits/develop (a 2.2 provider, but will be very similar to 3.x and 5)

Thanks @ErikEJ, I will go through details in the above link.

Meanwhile, I picked up Npgsql Postgres Provider from https://github.com/npgsql/efcore.pg repository and tried to do build with netcoreapp3.1 and observed build failures.

Opened issue https://github.com/npgsql/efcore.pg/issues/1471

Why are you building a third party provider ? - my advice was to reference the NuGet packages.

I need to build the new ".NET EF Core provider" for my database. I picked up SQLServer efcore code and made it work for my database (except scaffolding, that's where I opened this ticket!). Then I was suggested to use "Npgsql EF Core provider", which I am trying now, hence first I need to build existing code and with netstandard2.1 Framework the build works. I need to use netcoreapp3.1 (which I used for SQLServer efcore repository, which worked), our database's ".NET Core Provider" (which we built and released) uses netcoreapp3.1 framework, this ".NET Core Provider" shall be used to build ".NET EF Core Provider".

I do not understand your need to change your EF provider library to .NET Core 3.1 - any .NET Core 3.1 app can consume/use .NET Standard 2.1 libraries.

As I said before, reference these packages in your library, which should target .NET Standard 2.1:

 <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.7" />

In your functional test projects, reference:

<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="3.1.7" />

@ErikEJ - Because their client (equivalent of SqlClient) is .NET Core only.

@deokershesh - As previously mentioned few times in this thread.

  • If you are trying to build provider by forking efcore repo, it will never reach completion. 3rd party EF Core providers need to consume Microsoft.EntityFrameworkCore* packages through nuget and not via direct source. Otherwise you will run in all sorts of assembly mismatch issues. Even if you get all your tests to pass in your provider tests, no one else can use the package.
  • If your provider is special that it needs to use .netcoreapp only, then forking even 3rd party provider would be painful too. Each provider is customized for it's own needs and yours are different than what is out there. (Like you trying to build npgsql provider has 0 value. Neither you should be building it, nor filing for issues when it does not build).
  • Unless you are experienced with all the intricacies around structure of efcore (or even efcore.pg) repo for build related tasks, my advise is not get bogged with all that. That is the issue you are seeing while building efcore.pg right now.

Just create a .netcore class library which references your informix ADO.NET provider (through source project or nuget package is your choice) & Microsoft.EntityFrameworkCore.Relational package from nuget (this must be nuget package reference). And try writing tests against it. You can look into SqlServer provider source code for understanding of what needs to be implemented in your provider. Error messages in your tests would tell you what is not implemented in your provider and give you direction.

If you are not doing in above way then you are going to run into issue and it is not recommended way from us and I feel that it would be waste of resources for us trying to solve your issues of doing things wrong way which can be better used in fixing real bugs people have with EF Core as product.

Thanks for suggestions and guidance. I understand about not reporting build issues as I would have changed something which broke for me, if so better I fix it.

Yes, will refer SQL Server/NPGSQL EF Core Provider code to build one for my database. However, it would be good to have well written document which helps us from ground zero, like How to go about writing new EF Core Provider for your own database, from possibly .NET Core Foundation team.

https://github.com/dotnet/EntityFramework.Docs/issues/681 is tracking documentation on how to write a new EF Core provider.
Closing as there is nothing actionable remains here.

Was this page helpful?
0 / 5 - 0 ratings