The type or namespace name 'Server' could not be found (are you missing a using directive or an assembly reference?)
string connetionString = @"connectionStirng";
SqlConnection conn = new SqlConnection(connetionString);
var server = new Server(new ServerConnection(conn));
added at the top
using Microsoft.SqlServer.Management.Common;
Still giving error.
Any help appricated.
Already checked:
Why i'm getting error for the Microsoft.SqlServer.Server namespace?
I can't add Microsoft.SqlServer.Management.Common to my ASP.NET MVC Application
Install this nuget package:
https://www.nuget.org/packages/Microsoft.SqlServer.SqlManagementObjects
Then add using directive:
using Microsoft.SqlServer.Management.Smo;
Now you can create Server object.
var server = new Server();
Installing SMO
Beginning with SQL Server 2017 SMO is distributed as the Microsoft.SqlServer.SqlManagementObjects NuGet package to allow users to develop applications with SMO.
This is a replacement for SharedManagementObjects.msi, which was previously released as part of the SQL Feature Pack for each release of SQL Server. Applications that use SMO should be updated to use the NuGet package instead and will be responsible for ensuring the binaries are installed with the application being developed.