この文書の現在のバージョンと選択したバージョンの差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
dotnet:webapiチュートリアル [2022/09/01 14:01] ips |
dotnet:webapiチュートリアル [2022/09/01 14:10] (現在) ips |
||
---|---|---|---|
ライン 11: | ライン 11: | ||
</code> | </code> | ||
- | ===== dotnet-aspnet-codegenerator: command not found ===== | + | ===== エラー: dotnet-aspnet-codegenerator: command not found ===== |
このエラーがでてスキャフォールディングができない。 | このエラーがでてスキャフォールディングができない。 | ||
ライン 48: | ライン 48: | ||
</code> | </code> | ||
+ | ===== エラー: Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Migrations.IMigrator'. ===== | ||
+ | |||
+ | チュートリアルにあるUseInMemoryDatabaseを使っていると、dotnet ef(entity framework)が利用できない。 | ||
+ | |||
+ | <code> | ||
+ | # 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. | ||
+ | </code> | ||
+ | |||
+ | まずはqlserverのコンテナを作成して、そこにつなげる必要がある。 | ||
+ | 同じdockernetwork内のコンテナどうしなら、接続にコンテナ名が利用できる。 | ||
+ | ただしdocker-compsoeを使っていると、「project_db_1」のような名前になっているので注意。 | ||
+ | またホストのSSMS(SqlServer Management Stusido) から、コンテナのsqlseverにつなげる場合、すでにホストでSQLSERVERが起動していれば<html>127.0.0.1,14331</html>にする必要がある。 | ||
+ | ※localhostではつながらない。 | ||
+ | ※「:」ではなく「,」でポート番号を指定する必要がある。 | ||
+ | |||
+ | sqlserverの起動しているコンテナにexecする場合は | ||
+ | <code> | ||
+ | > docker exec -it project-dy-1 /opt/mssql-tools/bin/sqlcmd -U sa -P [password] | ||
+ | 1 > selecvt @@version | ||
+ | 2 > go | ||
+ | ~ | ||
+ | </code> | ||