https://github.com/nhatthaiquang-agilityio/dotnet-sqlserver-example
ASP Net Core API with SQL Server and Testing
https://github.com/nhatthaiquang-agilityio/dotnet-sqlserver-example
aspnetcore docker docker-compose dotnet sqlserver testing xunit
Last synced: 3 months ago
JSON representation
ASP Net Core API with SQL Server and Testing
- Host: GitHub
- URL: https://github.com/nhatthaiquang-agilityio/dotnet-sqlserver-example
- Owner: nhatthaiquang-agilityio
- Created: 2019-05-19T09:29:13.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-31T08:53:58.000Z (almost 4 years ago)
- Last Synced: 2025-04-09T12:29:44.277Z (about 1 year ago)
- Topics: aspnetcore, docker, docker-compose, dotnet, sqlserver, testing, xunit
- Language: C#
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dotnet SQL Server Example
ASP.NET Core API Server that uses SQL SERVER in the backend
### Requirements
-----------------
+ Using Docker & Docker Compose
+ NET CORE SDK 2.1 or 2.2
+ ASPNET RUNTIME 2.1 or 2.2
+ SQL SERVER
## Notes
---------
dotnet-sqlserver-example.sln using for Visual Studio
using src.sln for docker compose
ConnectionString in appsettings.json
+ Sql Server: still run in docker
+ Using docker-compose: `Server=db`
+ The app runs in Visual Studio then `Server=localhost`
### Issues
-----------
+ How to migrate database in docker compose. We need to start database and migrate database first and then start web app.
My bad solution:
+ Run `docker-compose up db`
+ dotnet ef migrations add InitialCreate
+ Run `docker-compose up web`
### Usage
----------
#### Migration database
```
cd src/dotnet-sqlserver-example
dotnet ef migrations add InitialCreate
```
#### Using Docker-Compose
```
cd devops
docker-compose up
```
#### Start project in Visual Studio
Open dotnet-sqlserver-example.csproj
Run sql server in docker and run code in visual studio
### Testing
------------
Apply Integration Test with In-Memory
```
cd src/Testing
dotnet test
```
### Reference
--------------
+ [Integration Testing](https://www.dotnetcurry.com/aspnet-core/1420/integration-testing-aspnet-core)