pzaloznyi / arch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running the sample

After cloning or downloading the sample you should be able to run it using an In Memory database immediately.

If you wish to use the sample with a persistent database, you will need to run its Entity Framework Core migrations before you will be able to run the app, and update the ConfigureServices method in Startup.cs (see below).

You can also run the samples in Docker (see below).

Configuring the sample to use SQL Server

  1. Update Startup.cs's ConfigureDevelopmentServices method as follows:
        public void ConfigureDevelopmentServices(IServiceCollection services)
        {
            // use in-memory database
            //ConfigureTestingServices(services);

            // use real database
            ConfigureProductionServices(services);

        }
  1. Ensure your connection strings in appsettings.json point to a local SQL Server instance.

  2. Open a command prompt in the Web folder and execute the following commands:

dotnet restore
dotnet ef database update -c catalogcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj
dotnet ef database update -c appidentitydbcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj

These commands will create two separate databases, one for the store's catalog data and shopping cart information, and one for the app's user credentials and identity data.

  1. Run the application. The first time you run the application, it will seed both databases with data such that you should see products in the store, and you should be able to log in using the demouser@onlineshop.com account.

Note: If you need to create migrations, you can use these commands:

-- create migration (from Web folder CLI)
dotnet ef migrations add InitialModel --context catalogcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj -o Data/Migrations

dotnet ef migrations add InitialIdentityModel --context appidentitydbcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj -o Identity/Migrations

Running the sample using Docker

You can run both the Web and WebRazorPages samples at the same time by running these commands from the root folder (where the .sln file is located):

    docker-compose build
    docker-compose up

You should be able to make requests to localhost:5006.

About


Languages

Language:C# 70.6%Language:HTML 20.6%Language:CSS 8.6%Language:Dockerfile 0.3%Language:JavaScript 0.0%