以前のリビジョンの文書です
Todoアプリを作成するのは以下のコンテナ。
FROM mcr.microsoft.com/dotnet/sdk:6.0
このエラーがでてスキャフォールディングができない。
dotnet tool install -g dotnet-aspnet-codegenerator
の後に
> cat << \EOF >> ~/.bash_profile # Add .NET Core SDK tools export PATH="$PATH:/roo/.dotnet/tools"
と
> export PATH="$PATH:/root/.donet/tools"
を入力する
# dotnet-aspnet-codegenerator controller -name TodoItemsController -async -api -m TodoItem -dc TodoContext -outDir Controllers Building project ... Finding the generator 'controller'... Running the generator 'controller'... Minimal hosting scenario! Attempting to compile the application in memory. Attempting to figure out the EntityFramework metadata for the model and DbContext: 'TodoItem' info: Microsoft.EntityFrameworkCore.Infrastructure[10403] Entity Framework Core 6.0.8 initialized 'TodoContext' using provider 'Microsoft.EntityFrameworkCore.InMemory:6.0.8' with options: StoreName=TodoList Added Controller : '/Controllers/TodoItemsController.cs'. RunTime 00:00:09.35
チュートリアルにあるUseInMemoryDatabaseを使っていると、dotnet ef(entity framework)が利用できない。
# dotnet ef migrations add initial Build started... Build succeeded. ~ Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Migrations.IMigrator'. This is often because no database provider has been configured for this DbContext. A provider can be configured by overriding the 'DbContext.OnConfiguring' method or by using 'AddDbContext' on the application service provider. If 'AddDbContext' is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.