title: VS2022 .NET 6.0 Scaffold-DbContext command error: Invalid column name for non-existent column
body: <p>I am trying to create model entities for use in LINQ in .NET Core 6.0 in VS 2022 since .edmx files are now deprecated.
  I am connecting to an existing SQL Server db at an external ISP using sql authentication.  The db has compatibility level SQL Server 2000 (80).
  I am using Windows 11 and Visual Studio 2022 version 17.2.3.</p>
  <p>The command I am using from Package Manager for the startup project (contains Program.cs) in this console app is:</p>
  <p>PM&gt; Scaffold-DbContext &quot;Server=my SQL Server Fully qualified domain name;Database=myDataBase;User Id=myUsername;Password=myPassword;&quot;  Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Tables myschema.mytable</p>
  <p>The error and detail I get is below and is essentially &quot;Invalid column name 'is_sparse'.&quot;  There is no is_sparse column in any table in this db.  I get the same error if I don't put the schema or I don't use the -Tables switch or I use an incorrect table name in that switch.  I am suspecting that I have a misconfiguration of some kind.</p>
  <p><strong>How do I fix this so I can get the entities and use them in LINQ queries?</strong></p>
  <p>Thanks in advance for any help on this.</p>
  <p><strong>Details:</strong></p>
  <p>Packages in the project (from parts of projectname/bin/Debug/net6.0/projectname.deps.json)</p>
  <pre><code>      &quot;DataRetrieval&quot;: &quot;1.0.0&quot;,
        &quot;Microsoft.EntityFrameworkCore.Design&quot;: &quot;6.0.6&quot;,
        &quot;Microsoft.EntityFrameworkCore.Tools&quot;: &quot;6.0.6&quot;,
        &quot;Microsoft.Extensions.Configuration&quot;: &quot;6.0.1&quot;,
        &quot;Microsoft.Extensions.Configuration.Binder&quot;: &quot;6.0.0&quot;,
        &quot;Microsoft.Extensions.Configuration.Json&quot;: &quot;6.0.0&quot;,
        &quot;Microsoft.Extensions.Configuration.UserSecrets&quot;: &quot;6.0.1&quot;,
        &quot;Microsoft.Extensions.Hosting&quot;: &quot;6.0.0&quot;,
        &quot;Microsoft.Extensions.Options&quot;: &quot;6.0.0&quot;,
        &quot;Newtonsoft.Json&quot;: &quot;13.0.1&quot;
        &quot;AutoMapper 11.0.1&quot;
        
    &quot;Microsoft.EntityFrameworkCore/6.0.6&quot;: {
      &quot;dependencies&quot;: {
        &quot;Microsoft.EntityFrameworkCore.Abstractions&quot;: &quot;6.0.6&quot;,
        &quot;Microsoft.EntityFrameworkCore.Analyzers&quot;: &quot;6.0.6&quot;,
        &quot;Microsoft.Extensions.Caching.Memory&quot;: &quot;6.0.1&quot;,
        &quot;Microsoft.Extensions.DependencyInjection&quot;: &quot;6.0.0&quot;,
        &quot;Microsoft.Extensions.Logging&quot;: &quot;6.0.0&quot;,
        &quot;System.Collections.Immutable&quot;: &quot;6.0.0&quot;,
        &quot;System.Diagnostics.DiagnosticSource&quot;: &quot;6.0.0&quot;
        
  </code></pre>
  <p><strong>Error:</strong>
  Here's the error from Package Manager (PM):</p>
  <p>PM&gt; Scaffold-DbContext &quot;Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;&quot;  Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Tables myschema.mytable
  Build started...
  Build succeeded.
  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 <a href="https://go.microsoft.com/fwlink/?linkid=2131148" rel="nofollow noreferrer">https://go.microsoft.com/fwlink/?linkid=2131148</a>. For more guidance on storing connection strings, see <a href="http://go.microsoft.com/fwlink/?LinkId=723263" rel="nofollow noreferrer">http://go.microsoft.com/fwlink/?LinkId=723263</a>.
  Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.
  Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid column name 'is_sparse'.
  at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action<code>1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action</code>1 wrapCloseInAction)
  at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
  at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady)
  at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
  at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData()
  at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
  at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task&amp; task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
  at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource<code>1 completion, Int32 timeout, Task&amp; task, Boolean&amp; usedCache, Boolean asyncWrite, Boolean inRetry, String method) at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.GetColumns(DbConnection connection, IReadOnlyList</code>1 tables, String tableFilter, String viewFilter, IReadOnlyDictionary<code>2 typeAliases, String databaseCollation) at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.GetTables(DbConnection connection, DatabaseModel databaseModel, Func</code>3 tableFilter, IReadOnlyDictionary<code>2 typeAliases, String databaseCollation) at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(DbConnection connection, DatabaseModelFactoryOptions options) at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions 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</code>1 schemas, IEnumerable<code>1 tables, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, 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</code>1 schemaFilters, IEnumerable<code>1 tableFilters, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluarlize) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.&lt;&gt;c__DisplayClass0_0.&lt;.ctor&gt;b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.&lt;&gt;c__DisplayClass3_0</code>1.b__0()
  at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
  ClientConnectionId:ba6b143c-3916-4582-a07f-5ea712131557
  Error Number:207,State:1,Class:16
  Invalid column name 'is_sparse'.</p>
  <p>Steve</p>