DropSchema.SqlServer
1.1.0
Requires NuGet 2.12 or higher.
dotnet add package DropSchema.SqlServer --version 1.1.0
NuGet\Install-Package DropSchema.SqlServer -Version 1.1.0
<PackageReference Include="DropSchema.SqlServer" Version="1.1.0" />
paket add DropSchema.SqlServer --version 1.1.0
#r "nuget: DropSchema.SqlServer, 1.1.0"
// Install DropSchema.SqlServer as a Cake Addin #addin nuget:?package=DropSchema.SqlServer&version=1.1.0 // Install DropSchema.SqlServer as a Cake Tool #tool nuget:?package=DropSchema.SqlServer&version=1.1.0
DropSchema SQL Server
When I write tests which have to work with a real SQL database, almost in each project in tests I have to repeat the pattern:
- Drop database schema
- Apply migrations
- Seed data
- Run test
This library - is my effort to save myself from carrying the "1. Drop database schema"
item as a raw code.
The librady scans the database schema you target and wipes all the tables/views/procedures/functions/etc so subsequent migrations can run on a "clean" database and give a predictable result.
Usage
Somewhere in your test infrastructure code:
public static void DropSchema()
{
//somehow get the connection string
//pls note, the user must have at least the
// db_ddladmin+db_datawriter+db_datareader permissions
string cs = GetDbConnectionString();
using var conn = new SqlConnection(cs);
using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
conn.Open();
new DropSchema(conn).Run("some-schema");//or "dbo" - the most often
}
And later in your test code:
[Test]
public void Test_MyMethod_Should_Do_Somethind_Nice()
{
DropSchema();
//apply migrations
//seed data
//run test
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.0 | 1,353 | 12/1/2022 |
1.0.0 | 4,998 | 6/8/2020 |
1.0.0-alpha1 | 492 | 6/4/2020 |