{"id":18508198,"url":"https://github.com/rudolphreti/asp.net-sql-docker-basics","last_synced_at":"2025-08-17T07:08:32.935Z","repository":{"id":250775039,"uuid":"833125817","full_name":"rudolphreti/ASP.NET-SQL-Docker-Basics","owner":"rudolphreti","description":"This project serves as an introduction to the basics of containerization using Docker. It covers application and SQL Server containerization, aiming to demonstrate the basic concepts and operation of Docker. The application is written in ASP.NET Core, C#, Entity Framework, MVC.","archived":false,"fork":false,"pushed_at":"2024-07-31T09:18:22.000Z","size":1010,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T09:51:31.617Z","etag":null,"topics":["asp-net-core","csharp","docker","mvc","sql"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/rudolphreti.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":"2024-07-24T12:03:53.000Z","updated_at":"2024-08-16T16:56:11.000Z","dependencies_parsed_at":"2024-07-30T02:54:09.155Z","dependency_job_id":"e9b7a2e0-570c-422c-9ba1-ebf61abbf862","html_url":"https://github.com/rudolphreti/ASP.NET-SQL-Docker-Basics","commit_stats":null,"previous_names":["rudolphreti/asp.net-mvc-demo","rudolphreti/asp.net-sql-docker-basics"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rudolphreti/ASP.NET-SQL-Docker-Basics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rudolphreti%2FASP.NET-SQL-Docker-Basics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rudolphreti%2FASP.NET-SQL-Docker-Basics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rudolphreti%2FASP.NET-SQL-Docker-Basics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rudolphreti%2FASP.NET-SQL-Docker-Basics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rudolphreti","download_url":"https://codeload.github.com/rudolphreti/ASP.NET-SQL-Docker-Basics/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rudolphreti%2FASP.NET-SQL-Docker-Basics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270817287,"owners_count":24650971,"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","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"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":["asp-net-core","csharp","docker","mvc","sql"],"created_at":"2024-11-06T15:13:42.760Z","updated_at":"2025-08-17T07:08:32.910Z","avatar_url":"https://github.com/rudolphreti.png","language":"HTML","readme":"# Project Overview\nThis project serves as an introduction to the basics of containerization using Docker. It covers application and SQL Server containerization, aiming to demonstrate the basic concepts and operation of Docker. The application is written in ASP.NET Core, C#, Entity Framework, MVC.\n\n## Requirements\n- Docker\n- .NET Core SDK\n- Visual Studio (with Docker integration enabled)\n- SQL Server Management Studio (optional, for database management)\n\n## Step by step\n* Create a new container:\ndocker run -e \"ACCEPT_EULA=Y\" -e \"SA_PASSWORD=meinStarkesPasswort123!\" -p 1433:1433 --name sqlserver -d mcr.microsoft.com/mssql/server:2022-latest\n\n* Make sure you have other services that use port 1433 disabled, e.g. another SQL server. Otherwise, it will not be possible to access the database: \n![SSMS-Screen](images/sqm.png)\n\n* Make a test connection in SQL Server Managment Studio: \n![SSMS-Screen](images/ssms.png)\n\n* Create database:\n```sql\nCREATE DATABASE TestDB;\nGO\n\nUSE TestDB;\nGO\n\nCREATE TABLE Person (\n    ID int NOT NULL PRIMARY KEY,\n    Name nvarchar(50) NULL\n);\nGO\n\nINSERT INTO Person (ID, Name) VALUES \n(1, 'John Smith'),\n(2, 'Emma Brown'),\n(3, 'Michael Johnson');\nGO\n```\n\n* Entity Framework scaffolding in Visual Studio -\u003e Package Manager Console:\n```bash\nScaffold-DbContext \"Server=localhost,1433;Database=TestDB;User Id=sa;Password=meinStarkesPasswort123!;Encrypt=false;\" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Data -f\n```\n\n* Running the Application:\n\nRun with Docker Container .NET SDK. Visual Studio automates the process of running the Dockerized application. Simply open the solution in Visual Studio, and it will manage the Docker containers for the application automatically.\n\nAs a result, the Person table should be displayed:\n![SSMS-Screen](images/result.png)\n\n\n## TO DO\nThere are problems with connection strings. Entity Framework scaffolding works with localhost:\n```bash\nScaffold-DbContext \"Server=localhost,1433;Database=TestDB;User Id=sa;Password=meinStarkesPasswort123!;Encrypt=false;\" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Data -f\n```\n\nScaffolding generates the TestDBContext.cs file, where the connection string appears:\n```c#\noptionsBuilder.UseSqlServer(“Server=localhost,1433;Database=TestDB;User Id=sa;Password=meinStarkesPasswort123!;Encrypt=false;”);\n```\nIn order for the application to work properly, in this connection string you need to replace the \"localhost\" with the ip of the container, and you can get it this way:\n```bash\ndocker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' sqlserver\n```\nOutput could be 172.17.0.2, for example, so the connection string in TestDBContext.cs should look like this:\n```c#\noptionsBuilder.UseSqlServer(“Server=172.17.0.2,1433;Database=TestDB;User Id=sa;Password=meinStarkesPasswort123!;Encrypt=false;”);\n```\nThe same connection string should be in appsettings.json:\n```json\n„ConnectionStrings\": {\n  „DefaultConnection\": „Server=172.17.0.2,1433;Database=TestDB;User Id=sa;Password=meinStarkesPasswort123!;Encrypt=false;”\n},\n```\nEverything would be simpler if scaffolding could be done using ip container. The question is how to do it? \n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frudolphreti%2Fasp.net-sql-docker-basics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frudolphreti%2Fasp.net-sql-docker-basics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frudolphreti%2Fasp.net-sql-docker-basics/lists"}