{"id":19620578,"url":"https://github.com/adamfoneil/sqlserver.localdb","last_synced_at":"2026-05-17T02:40:30.456Z","repository":{"id":115833833,"uuid":"224544813","full_name":"adamfoneil/SqlServer.LocalDb","owner":"adamfoneil","description":"Utilities for SQL Server integration testing with LocalDb","archived":false,"fork":false,"pushed_at":"2024-01-24T00:54:44.000Z","size":52,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-21T11:07:22.740Z","etag":null,"topics":["integration-testing","localdb","sql-server"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamfoneil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-11-28T01:15:23.000Z","updated_at":"2024-01-24T00:54:45.000Z","dependencies_parsed_at":"2023-06-09T08:00:48.732Z","dependency_job_id":null,"html_url":"https://github.com/adamfoneil/SqlServer.LocalDb","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfoneil%2FSqlServer.LocalDb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfoneil%2FSqlServer.LocalDb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfoneil%2FSqlServer.LocalDb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfoneil%2FSqlServer.LocalDb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamfoneil","download_url":"https://codeload.github.com/adamfoneil/SqlServer.LocalDb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240914827,"owners_count":19878050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["integration-testing","localdb","sql-server"],"created_at":"2024-11-11T11:19:19.325Z","updated_at":"2025-10-15T03:11:25.761Z","avatar_url":"https://github.com/adamfoneil.png","language":"C#","funding_links":["https://paypal.me/adamosoftware"],"categories":[],"sub_categories":[],"readme":"[![Nuget](https://img.shields.io/nuget/v/SqlServer.LocalDb.Testing)](https://www.nuget.org/packages/SqlServer.LocalDb.Testing/)\n\nThis is a small library of static methods to help you write integration tests for SQL Server. It creates databases dynamically on your localdb instance, and frees you from maintaining a connection string and related config overhead. You can also initialize databases with seed objects and data via SQL statements or any arbitrary initialization.\n\nTo use, install nuget package **SqlServer.LocalDb.Testing**\n\nThen, in your integration tests that require a LocalDb connection, you can write code like this:\n\n```csharp\nusing (var cn = LocalDb.GetConnection(\"sample\"))\n{\n  // whatever testing you need to do\n}\n```\nThis will open or create a database named `sample` at **(localdb)\\mssqllocaldb**\n\nI didn't try too hard to implement deletion of sample databases because I have found deleting databases at runtime to be pretty fussy. I figure if you are running tests in an environment like AppVeyor, then you get a clean environment with every build. So, I felt that deleting databases as a cleanup activity was just not necessary.\n\nI looked around and saw a couple other libraries doing exactly what I set out to do here, which was interesting to see. Maybe I should've looked around before writing mine, but I enjoy stuff like this -- so here we are!\n\n## Examples\n- [Create database with sample model](https://github.com/adamosoftware/SqlIntegration/blob/master/Testing/SqlMigratorTest.cs#L44), sample model is [here](https://github.com/adamosoftware/SqlIntegration/blob/master/Testing/SqlMigratorTest.cs#L177), and random data creation is [here](https://github.com/adamosoftware/SqlIntegration/blob/master/Testing/SqlMigratorTest.cs#L127)\n- [Drop sample db on test class startup](https://github.com/adamosoftware/SqlIntegration/blob/master/Testing/SqlMigratorTest.cs#L28)\n- [Another test class initialize example](https://github.com/adamfoneil/Dapper.CX/blob/master/Tests.SqlServer/SqlServer/SqlServerIntegration.cs#L19)\n- [Yet another test class initialize, with random data](https://github.com/adamosoftware/Dapper.QX/blob/master/Testing/ExecutionSqlServer.cs#L25), using my [Test Data Generation](https://github.com/adamosoftware/TestDataGen) library.\n- Side note: Random data persistence is handled by my [BulkInsert](https://github.com/adamosoftware/SqlIntegration/blob/master/SqlIntegration.Library/BulkInsert.cs) helper from my [SqlIntegration](https://github.com/adamosoftware/SqlIntegration) project.\n\n\n## Reference [LocalDb.cs](https://github.com/adamfoneil/SqlServer.LocalDb/blob/master/SqlServer.LocalDb/LocalDb.cs#L10)\n- string [GetConnectionString](https://github.com/adamfoneil/SqlServer.LocalDb/blob/master/SqlServer.LocalDb/LocalDb.cs#L12)\n (string databaseName)\n- SqlConnection [GetConnection](https://github.com/adamfoneil/SqlServer.LocalDb/blob/master/SqlServer.LocalDb/LocalDb.cs#L17)\n (string databaseName, IEnumerable\u003cInitializeStatement\u003e initializeStatements)\n- void [ExecuteInitializeStatements](https://github.com/adamfoneil/SqlServer.LocalDb/blob/master/SqlServer.LocalDb/LocalDb.cs#L25)\n (SqlConnection cn, IEnumerable\u003cInitializeStatement\u003e statements)\n- SqlConnection [GetConnection](https://github.com/adamfoneil/SqlServer.LocalDb/blob/master/SqlServer.LocalDb/LocalDb.cs#L52)\n (string databaseName, [ Action\u003cSqlConnection\u003e initialize ])\n- bool [TryDropDatabase](https://github.com/adamfoneil/SqlServer.LocalDb/blob/master/SqlServer.LocalDb/LocalDb.cs#L93)\n (string databaseName, string message)\n- bool [TryDropDatabaseIfExists](https://github.com/adamfoneil/SqlServer.LocalDb/blob/master/SqlServer.LocalDb/LocalDb.cs#L122)\n (string databaseName, string message)\n- bool [ObjectExists](https://github.com/adamfoneil/SqlServer.LocalDb/blob/master/SqlServer.LocalDb/LocalDb.cs#L166)\n (SqlConnection connection, string objectName)\n- void [ExecuteIfExists](https://github.com/adamfoneil/SqlServer.LocalDb/blob/master/SqlServer.LocalDb/LocalDb.cs#L182)\n (SqlConnection connection, string objectName, string execute)\n\n## Hi there\nIf by a crazy turn of events, you find this useful, please consider [buying me a coffee](https://paypal.me/adamosoftware).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamfoneil%2Fsqlserver.localdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamfoneil%2Fsqlserver.localdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamfoneil%2Fsqlserver.localdb/lists"}