diff --git a/readme.md b/readme.md
index 9ff4eec..bd57d12 100644
--- a/readme.md
+++ b/readme.md
@@ -50,7 +50,7 @@ This test:
```cs
await Verify(connection);
```
-snippet source | anchor
+snippet source | anchor
Will result in the following verified file:
@@ -69,7 +69,7 @@ await Verify(connection)
// include only tables and views
.SchemaIncludes(DbObjects.Tables | DbObjects.Views);
```
-snippet source | anchor
+snippet source | anchor
Available values:
@@ -107,7 +107,7 @@ await Verify(connection)
_ => _ is TableViewBase ||
_.Name == "MyTrigger");
```
-snippet source | anchor
+snippet source | anchor
@@ -129,7 +129,7 @@ command.CommandText = "select Value from MyTable";
var value = await command.ExecuteScalarAsync();
await Verify(value!);
```
-snippet source | anchor
+snippet source | anchor
Will result in the following verified file:
@@ -184,7 +184,7 @@ await Verify(
sqlEntries = entries
});
```
-snippet source | anchor
+snippet source | anchor
@@ -212,7 +212,7 @@ var sqlErrorsViaType = entries
.Select(_ => _.Data)
.OfType();
```
-snippet source | anchor
+snippet source | anchor
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index c5949c1..07b6c9d 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -2,7 +2,7 @@
CS1591;CS0649;CS8632;NU1608;NU1109
- 12.1.0
+ 12.1.1
preview
1.0.0
SqlServer, Verify
diff --git a/src/Tests/Tests.cs b/src/Tests/Tests.cs
index ad9c378..ffc2445 100644
--- a/src/Tests/Tests.cs
+++ b/src/Tests/Tests.cs
@@ -8,9 +8,10 @@ static Tests() =>
"VerifySqlServer",
connection =>
{
- var serverConnection = new ServerConnection();
- SqlScriptBuilder.SqlConnectionObjectField.SetValue(serverConnection, connection);
- serverConnection.NonPooledConnection = true;
+ var serverConnection = new ServerConnection
+ {
+ ConnectionString = connection.ConnectionString,
+ };
var server = new Server(serverConnection);
server.ConnectionContext.ExecuteNonQuery(
"""
diff --git a/src/Verify.SqlServer/SchemaValidation/SqlScriptBuilder.cs b/src/Verify.SqlServer/SchemaValidation/SqlScriptBuilder.cs
index 4a26f17..18c1bf2 100644
--- a/src/Verify.SqlServer/SchemaValidation/SqlScriptBuilder.cs
+++ b/src/Verify.SqlServer/SchemaValidation/SqlScriptBuilder.cs
@@ -1,20 +1,5 @@
class SqlScriptBuilder(SchemaSettings settings)
{
- // TODO: when Microsoft.Data.SqlClient 7.0.1 adds TypeForwardedTo for SqlAuthenticationMethod,
- // revert to using new ServerConnection(SqlConnection) and remove this reflection workaround.
- //
- // SMO 181.15.0 ServerConnection(SqlConnection) constructor calls InitFromSqlConnection
- // which references SqlAuthenticationMethod — a type moved from Microsoft.Data.SqlClient
- // to Microsoft.Data.SqlClient.Extensions.Abstractions in SqlClient 7.0. The CLR can't
- // resolve the type in the original assembly, causing a TypeLoadException.
- //
- // Workaround: construct ServerConnection() with default constructor (no InitFromSqlConnection),
- // then set the internal m_SqlConnectionObject field via reflection to reuse the open connection.
- // SMO detects the connection is already open and uses it directly.
- internal static readonly FieldInfo SqlConnectionObjectField =
- typeof(ConnectionManager).GetField("m_SqlConnectionObject", BindingFlags.NonPublic | BindingFlags.Instance) ??
- throw new("Could not find field m_SqlConnectionObject on ConnectionManager. The SMO internals may have changed.");
-
static Dictionary tableSettingsToScrubLookup;
static SqlScriptBuilder()
@@ -50,7 +35,6 @@ public string BuildContent(SqlConnection connection)
};
try
{
- SqlConnectionObjectField.SetValue(serverConnection, connection);
var server = new Server(serverConnection);
return BuildContent(server, builder);
}