This project was created with Craftsman.
This project is configured to reference a live database instead of an in-memory one for more robust development. By default, the database will be configured to run in a docker container and already has the connection string configured in your launch settings.
To set up your database(s):
- Run
docker-compose up --build
from yoursln
directory to spin up your database(s) (and RabbitMQ, if needed).
After you have your database(s) running in docker, make sure you apply your migrations:
- Make sure you have a migrations in your boundary project (there should be a
Migrations
directory in the project directory). If there isn't see Running Migrations below. - Confirm your environment (
ASPNETCORE_ENVIRONMENT
) is set toDevelopment
using$Env:ASPNETCORE_ENVIRONMENT = "Development"
for powershell orexport ASPNETCORE_ENVIRONMENT=Development
for bash. cd
to the boundary project root (e.g.cd RecipeManagement/src/RecipeManagement
)- Run
dotnet ef database update
to apply your migrations.
You can also stay in the
sln
root and run something likedotnet ef database update --project RecipeManagement/src/RecipeManagement
Once you have your database(s) running, you can run your API(s), BFF, and Auth Servers by using
the dotnet run
command or running your project(s) from your IDE of choice.
To run integration tests:
- Ensure that you have docker installed.
- Go to your src directory for the bounded context that you want to test.
- Confirm that you have migrations in your infrastructure project. If you need to add them, see the instructions below.
- Run the tests
⏳ If you don't have the database image pulled down to your machine, they will take some time on the first run.
-If you have trouble with your tests, try removing the container and volume marked for your integration tests.
- If your entity has foreign keys, you'll likely need to adjust some of your tests after scaffolding to accomodate them.
To create a new migration, make sure your environment is set to Development
:
$Env:ASPNETCORE_ENVIRONMENT = "Development"
export ASPNETCORE_ENVIRONMENT=Development
Then run the following:
cd YourBoundedContextName/src/YourBoundedContextName
dotnet ef migrations add "MigrationDescription"
To apply your migrations to your local db, make sure your database is running in docker run the following:
cd YourBoundedContextName/src/YourBoundedContextName
dotnet ef database update