{"id":22065741,"url":"https://github.com/karenpayneoregon/localdb-samples","last_synced_at":"2026-04-16T04:01:34.357Z","repository":{"id":110840622,"uuid":"435196631","full_name":"karenpayneoregon/localdb-samples","owner":"karenpayneoregon","description":"Learn to create SQL-Server LocalDb in code and more","archived":false,"fork":false,"pushed_at":"2022-02-12T13:04:25.000Z","size":219,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T18:17:17.967Z","etag":null,"topics":["csharp-core","localdb","sql","sql-server"],"latest_commit_sha":null,"homepage":"","language":"TSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karenpayneoregon.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-05T14:55:41.000Z","updated_at":"2021-12-14T22:05:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"03d80595-cee4-4b63-8d3b-3b0d1ee48ae2","html_url":"https://github.com/karenpayneoregon/localdb-samples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/karenpayneoregon/localdb-samples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Flocaldb-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Flocaldb-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Flocaldb-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Flocaldb-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karenpayneoregon","download_url":"https://codeload.github.com/karenpayneoregon/localdb-samples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karenpayneoregon%2Flocaldb-samples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31870516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["csharp-core","localdb","sql","sql-server"],"created_at":"2024-11-30T19:21:42.561Z","updated_at":"2026-04-16T04:01:34.338Z","avatar_url":"https://github.com/karenpayneoregon.png","language":"TSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"![img](assets/csharpSqlServer.png)\n\n# Working with SQL-Server Express-LocalDb\n\nThis repository has code samples for working with SQL-Server [LocalDb](https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-express-localdb?view=sql-server-ver15) databases using C# 9 (or higher), .NET Core 5 (or higher). Each code sample will have a readme file explaining purpose and details on how to use plus any caveats.\n\n# Recommended\n\nExpected developer experience level, has a decent understanding for working with SQL and Entity Framework Core.\n\n---\n\nMicrosoft SQL Server Express LocalDB is a feature of SQL Server Express targeted to developers. \n\n\u003e LocalDB is a special, low impact version of the SQL Server engine, that is not installed as a Windows Service, but launched (made to run) on demand by the ADO.NET client opening a connection to it. It is intended for single user scenarios, and not for any production use - for production you should use SQL Server Express (or higher)\n\n[ErikEJ](http://erikej.blogspot.com/2011/01/comparison-of-sql-server-compact-4-and.html)\n\n\n![image](assets/screen1.png)\n\n- **12/05/2021** Only one code sample, how to create a localDb in code. \n- **12/14/2021** Added code in LocalDbLibraryConsoleApp to create a LocalDb version of NorthWind database\n- **12/14/2021** Added Entity Framework Core 5 class project which relies on LocalDbLibraryConsoleApp to first create the database.\n \n\n\n| Project  | Description\n| :--- | :--- |\n| LocalDbLibrary | Code to create a localDb in code |\n| NorthWindLibrary | Uses NorthWind database created in project LocalDbLibraryConsoleApp |\n| LocalDbLibraryConsoleApp | Test project for LocalDbLibrary |\n\n# Special note\n\nCreating the database in the console app then attempting to in the windows form app or reverse will cause a runtime exception as the database can not be duplicated. So after running one of the projects and want to run the other detach/delete the first database which is easy in SSMS.\n\n# Requires\n\n- SQL Server Express [LocalDB](https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-express-localdb?view=sql-server-ver15) installed\n- Visual Studio 2019 or higher\n- In some cases proper permissions to SQL-Server\n \n# Recommendations\n\nHave [SSMS](https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15) (SQL-Server Management Studio) installed\n\n#### See also\n\n[SqlLocalDB Utility](https://docs.microsoft.com/en-us/sql/tools/sqllocaldb-utility?view=sql-server-ver15)\n\n[Command-Line Management Tool: SqlLocalDB.exe](https://docs.microsoft.com/en-us/sql/relational-databases/express-localdb-instance-apis/command-line-management-tool-sqllocaldb-exe?view=sql-server-ver15)\n\nSqlLocalDB.exe is a simple tool that enables the user to easily manage LocalDB instances from the command line. It is implemented as a simple wrapper around the LocalDB instance API. As in many similar SQL Server tools (for example, SQLCMD), parameters are passed to SqlLocalDB as command-line arguments and output is sent to the console.\n\n\nUse the **SqlLocalDB utility** to create an instance of MicrosoftSQL Server 2016 Express **LocalDB**. The SqlLocalDB utility (SqlLocalDB.exe) is a simple command line tool to enable users and developers to create and manage an instance of SQL Server Express LocalDB. For information about how to use LocalDB.\n\n[Create a SQL Server Database programmatically by using ADO.NET and Visual C# .NET](https://docs.microsoft.com/en-us/troubleshoot/dotnet/csharp/create-sql-server-database-programmatically)\n\nThis article describes how to create a SQL Server Database programmatically by using ADO.NET and Visual C# .NET. Which is from Microsoft which is good but lacks details and options found in LocalDbLibrary.Classes.[DataOperations](https://github.com/karenpayneoregon/localdb-samples/blob/master/LocalDbLibrary/Classes/DataOperations.cs)\n\n[Creating a Connection String and Working with SQL Server LocalDB](https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/introduction/creating-a-connection-string)\n\n# Version details\n\nFrom a command prompt `sqllocaldb.exe i` to get instances on a machince then to get information for a speccific instance `sqllocaldb.exe i \"MSSQllocalDB\"`.\n\n![img](assets/localDbInfo.png)\n\n\n \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarenpayneoregon%2Flocaldb-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarenpayneoregon%2Flocaldb-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarenpayneoregon%2Flocaldb-samples/lists"}