Closed yuryjhol closed 3 years ago
Note for triage: I am able to reproduce this. Full output below:
PS C:\local\AllTogetherNow\Daily> dotnet ef dbcontext scaffold "Server=localhost;Database=WideWorldImporters;Trusted_Connection=True" Microsoft.EntityFrameworkCore.SqlServer --verbose
Using project 'C:\local\AllTogetherNow\Daily\Daily.csproj'.
Using startup project 'C:\local\AllTogetherNow\Daily\Daily.csproj'.
Writing 'C:\local\AllTogetherNow\Daily\obj\Daily.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\ajcvi\AppData\Local\Temp\tmp1EF7.tmp /verbosity:quiet /nologo C:\local\AllTogetherNow\Daily\Daily.csproj
Writing 'C:\local\AllTogetherNow\Daily\obj\Daily.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\ajcvi\AppData\Local\Temp\tmp209E.tmp /verbosity:quiet /nologo C:\local\AllTogetherNow\Daily\Daily.csproj
Build started...
dotnet build C:\local\AllTogetherNow\Daily\Daily.csproj /verbosity:quiet /nologo
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.11
Build succeeded.
dotnet exec --depsfile C:\local\AllTogetherNow\Daily\bin\Debug\net6.0\Daily.deps.json --additionalprobingpath C:\Users\ajcvi\.nuget\packages --runtimeconfig C:\local\AllTogetherNow\Daily\bin\Debug\net6.0\Daily.runtimeconfig.json C:\Users\ajcvi\.nuget\packages\dotnet-ef\6.0.0-rc.2.21430.16\tools\netcoreapp3.1\an
y\tools\netcoreapp2.0\any\ef.dll dbcontext scaffold Server=localhost;Database=WideWorldImporters;Trusted_Connection=True Microsoft.EntityFrameworkCore.SqlServer --assembly C:\local\AllTogetherNow\Daily\bin\Debug\net6.0\Daily.dll --project C:\local\AllTogetherNow\Daily\Daily.csproj --startup-assembly C:\local\Al
lTogetherNow\Daily\bin\Debug\net6.0\Daily.dll --startup-project C:\local\AllTogetherNow\Daily\Daily.csproj --project-dir C:\local\AllTogetherNow\Daily\ --root-namespace "" --language C# --framework net6.0 --working-dir C:\local\AllTogetherNow\Daily --verbose
Using assembly 'Daily'.
Using startup assembly 'Daily'.
Using application base 'C:\local\AllTogetherNow\Daily\bin\Debug\net6.0'.
Using working directory 'C:\local\AllTogetherNow\Daily'.
Using root namespace ''.
Using project directory 'C:\local\AllTogetherNow\Daily\'.
Remaining arguments: .
Finding design-time services referenced by assembly 'Daily'...
Finding design-time services referenced by assembly 'Daily'...
Using design-time services from assembly 'Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite'.
Finding design-time services for provider 'Microsoft.EntityFrameworkCore.SqlServer'...
Using design-time services from provider 'Microsoft.EntityFrameworkCore.SqlServer'.
Finding IDesignTimeServices implementations in assembly 'Daily'...
No design-time services were found.
To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection st
rings, see http://go.microsoft.com/fwlink/?LinkId=723263.
System.ArgumentNullException: Value cannot be null. (Parameter 'name')
at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
at Microsoft.EntityFrameworkCore.Metadata.IReadOnlyEntityType.GetProperty(String name)
at Microsoft.EntityFrameworkCore.Metadata.IEntityType.GetProperty(String name)
at Microsoft.EntityFrameworkCore.SqlServer.Metadata.Internal.SqlServerAnnotationProvider.For(IColumn column, Boolean designTime)+MoveNext()
at Microsoft.EntityFrameworkCore.Infrastructure.AnnotatableBase.AddAnnotations(AnnotatableBase annotatable, IEnumerable`1 annotations)
at Microsoft.EntityFrameworkCore.Infrastructure.AnnotatableBase.AddAnnotations(IEnumerable`1 annotations)
at Microsoft.EntityFrameworkCore.Metadata.Internal.RelationalModel.Create(IModel model, IRelationalAnnotationProvider relationalAnnotationProvider, Boolean designTime)
at Microsoft.EntityFrameworkCore.Metadata.Internal.RelationalModel.Add(IModel model, IRelationalAnnotationProvider relationalAnnotationProvider, Boolean designTime)
at Microsoft.EntityFrameworkCore.Infrastructure.RelationalModelRuntimeInitializer.InitializeModel(IModel model, Boolean designTime, Boolean prevalidation)
at Microsoft.EntityFrameworkCore.Infrastructure.ModelRuntimeInitializer.Initialize(IModel model, Boolean designTime, IDiagnosticsLogger`1 validationLogger)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.Create(DatabaseModel databaseModel, ModelReverseEngineerOptions options)
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, IEnumerable`1 schemas, IEnumerable`1 tables, String modelNamespace, String contextNamespace, Boolean useDataAnnot
ations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluralize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, String modelNamespace, String contextNamespace, Boolean useD
ataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluarlize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.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)
Value cannot be null. (Parameter 'name')
DatabaseModel created with these annotations (TemporalPeriodStartColumnName and TemporalPeriodEndColumnName). But on creating metadata model (IModel) IScaffoldingModelFactory trying to read (TemporalPeriodStartPropertyName and TemporalPeriodEndPropertyName).
See: SqlServerDatabaseModelFactory.cs method GetTables Code lines: table[SqlServerAnnotationNames.TemporalPeriodStartColumnName] = periodStartColumnName;
and code of class SqlServerModelValidator that on validating use TemporalPeriodStartPropertyName and TemporalPeriodEndPropertyName annotation names