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

Scaffolding synapse fails when attempting to enumerate triggers #30998

Closed
memory-thrasher opened this issue May 30, 2023 · 7 comments · Fixed by #31011
Closed

Scaffolding synapse fails when attempting to enumerate triggers #30998

memory-thrasher opened this issue May 30, 2023 · 7 comments · Fixed by #31011
Labels
area-scaffolding area-sqlserver closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. community-contribution customer-reported Servicing-approved type-bug
Milestone

Comments

@memory-thrasher
Copy link
Contributor

Synapse does not support triggers. Attempting to read fro mthe table sys.triggers via ssms results in the error: Catalog view 'triggers' is not supported in this version. Starting with efcore version 7.0.0, the scaffold process attempts to enumerate triggers, and fails with the same error message, with the stack trace below. The command requesting the scaffold is also below.

The file src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs, which is responsible for enumerating all db objects during scaffolding, has other code that specifically behaves differently when run on synapse (by engine edition), and many of them have been added since version 7 but as of 5/25, triggers are still not filtered by engine edition. Therefore, I request a change, that triggers not be enumerated when scaffolding synapse. Furthermore, since we are not able to support efcore 8.x at this time, I request a patched 7.0.x release be published with this fix.

I have tested a simple code change does allow the scaffold to complete and am in the process of validating the output. I intend to submit a pull request in the near future for this issue against 7.0.x

dotnet-ef dbcontext scaffold --no-build "$connString" Microsoft.EntityFrameworkCore.SqlServer --schema STARS --output-dir Models -f -c SynapseContextModel --startup-project . --project . --no-pluralize
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 strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
Microsoft.Data.SqlClient.SqlException (0x80131904): Catalog view 'triggers' is not supported in this version.
   at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlConnection.cs:line 2010
   at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\src\Microsoft\Data\SqlClient\SqlInternalConnection.cs:line 770
   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\TdsParser.cs:line 1404
   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\TdsParser.cs:line 1975
   at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData() in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlDataReader.cs:line 1142
   at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData() in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlDataReader.cs:line 260
   at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlCommand.cs:line 5124
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlCommand.cs:line 4937
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlCommand.cs:line 4621
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlCommand.cs:line 4491
   at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlCommand.cs:line 2038
   at Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) in D:\a\_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlCommand.cs:line 2000
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.GetTriggers(DbConnection connection, IReadOnlyList`1 tables, String tableFilter)
   at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.GetTables(DbConnection connection, DatabaseModel databaseModel, Func`3 tableFilter, IReadOnlyDictionary`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`1 schemas, IEnumerable`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`1 schemaFilters, IEnumerable`1 tableFilters, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluralize)
   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)
ClientConnectionId: [redacted]
Error Number:104385,State:1,Class:16
Catalog view 'triggers' is not supported in this version.

EF Core version: 7.0.4 and 8.0.23-preview
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0
Operating system: 11
IDE: N/A (dotnet cli)

@ErikEJ
Copy link
Contributor

ErikEJ commented May 30, 2023

I can fix this today for EF Core Power Tools, if you are interested?

@ErikEJ
Copy link
Contributor

ErikEJ commented May 30, 2023

Fixed for EF Core 7 in latest daily build of EF Core Power Tools, and CLI version rc.2

@memory-thrasher
Copy link
Contributor Author

@ErikEJ That is probably a good move in general but we're not using power tools so I'm still working on fixing it in the ef core. I will be submitting a PR shortly.

memory-thrasher added a commit to memory-thrasher/efcore that referenced this issue May 30, 2023
@memory-thrasher
Copy link
Contributor Author

PR here
#31001

@memory-thrasher
Copy link
Contributor Author

New PR here (tageting main as requested)
#31011

memory-thrasher added a commit to memory-thrasher/efcore that referenced this issue May 31, 2023
@memory-thrasher
Copy link
Contributor Author

PR approved and tests have passed. I don't have permissions to merge it.
I would like to reiterate my request to have this fix backported to 7.x so I can actually use it. Otherwise I'm happy.

@roji
Copy link
Member

roji commented Jun 1, 2023

Reopening to consider servicing.

@roji roji reopened this Jun 1, 2023
@ajcvickers ajcvickers added this to the 7.0.x milestone Jun 8, 2023
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 8, 2023
@ajcvickers ajcvickers modified the milestones: 7.0.x, 7.0.9 Jun 19, 2023
@ajcvickers ajcvickers removed this from the 7.0.9 milestone Jul 6, 2023
@ajcvickers ajcvickers added this to the 7.0.10 milestone Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-scaffolding area-sqlserver closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. community-contribution customer-reported Servicing-approved type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants