ErikEJ / EFCorePowerTools

Entity Framework Core Power Tools - reverse engineering, migrations and model visualization in Visual Studio & CLI
MIT License
2.15k stars 294 forks source link

System.ArgumentException: Keyword not supported: 'trust server certificate' #1725

Closed zackhowe closed 1 year ago

zackhowe commented 1 year ago

When trying to open/edit a efpt reverse engineer project with a data connection that has Trust Server Certificate defined (either true or false) the action fails with an error in the extension output.

Provide steps to reproduce

Create a Data Connection that defines Trust Server Certificate in the Advanced Settings. When it is initially defaulted to False, and not displayed as bold, It is not added to the connection string, and the reverse engineer works as expected. Once set the True (or False) the ";Trust Server Certificate=True" is append to the Connection String.

Now choose EF Power Tools - Edit and an error appears in the output:

System.ArgumentException: Keyword not supported: 'trust server certificate'.
   at NameValuePair System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, string connectionString, bool buildChain, Hashtable synonyms, bool firstKey)
   at new System.Data.Common.DbConnectionOptions(string connectionString, Hashtable synonyms, bool useOdbcRules)
   at new System.Data.SqlClient.SqlConnectionString(string connectionString)
   at DbConnectionOptions System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(string connectionString, DbConnectionOptions previous)
   at DbConnectionPoolGroup System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, ref DbConnectionOptions userConnectionOptions)
   at void System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
   at void System.Data.SqlClient.SqlConnection.set_ConnectionString(string value)
   at new System.Data.SqlClient.SqlConnection(string connectionString, SqlCredential credential)
   at Tuple<bool, Version> EFCorePowerTools.Helpers.ReverseEngineerHelper.HasSqlServerViewDefinitionRightsAndVersion(string connectionString)
   at void EFCorePowerTools.Handlers.ReverseEngineer.ReverseEngineerHandler.VerifySQLServerRightsAndVersion(ReverseEngineerOptions options)
   at async Task EFCorePowerTools.Handlers.ReverseEngineer.ReverseEngineerHandler.ReverseEngineerCodeFirstAsync(Project project, string optionsPath, bool onlyGenerate, bool fromSqlProj)

Provide technical details

ErikEJ commented 1 year ago

@zackhowe I assume you are using VS 17.5 with the new Microsoft Data SqlClient DDEX provider?

zackhowe commented 1 year ago

@ErikEJ 17.5.1 Not sure about the DDEX provider. I think this was working prior to a recent VS update....

ErikEJ commented 1 year ago

I implemented a fix for this in the latest daily build, would be grateful if you could try it out.

If you like my free tools, I would be very grateful for a rating or review on Visual Studio Marketplace or even a one-time or monthly sponsorship

zackhowe commented 1 year ago

@ErikEJ I was just able to successfully edit/reverse engineer using a connection with the Trust Server Certificate set. Thanks for the speedy fix!