Search code examples
c#.net.net-coresmo

Microsoft SqlServer Management: method not found creating a ServerConnection


Microsoft.SqlServer.SqlManagementObjects 161.47027.0

Microsoft.Data.SqlClient 5.0.0

After upgrading Microsoft.Data.SqlClient from 4.1.0 to 5.0.0 I got this error creating a ServerConnection object:

using Microsoft.SqlServer.Management.Common;

var serverConnection = new ServerConnection("localhost", "sa", "mypwd");

System.MissingMethodException: 'Method not found: 'Void Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Encrypt(Boolean)

It looks for a not implemented set_Encrypt method inside a Microsoft.Data.SqlClient.SqlConnectionStringBuilder

Does it mean Microsoft.SqlServer.SqlManagementObjects has not been updated yet to support Microsoft.Data.SqlClient 5.0.0?

If so do I need to wait for this update before I can upgrade Microsoft.Data.SqlClient 5.0.0 into my project?


Solution

  • You can also upgrade the ServerManagementObjects reference to 170.7.0-preview to resolve. Apparently the issue is with the smo library not the sqlclient library. https://github.com/dotnet/SqlClient/issues/1702

    Their code should be backwards compatible, but they need to be recompiled against MDS 5.0