EF Core migrations using asp.net core, SQL Server and Docker yields dotnet SDK error

asp.net-core docker entity-framework-core sql-server

Question

I'm using Docker for Windows Version 1.13.0-rc5-beta35 (9606)

Windows 10 Pro

Visual Studio Code


I've created an ASP.NET Core project with Docker using the yeoman generator:

yo aspnet
yo docker

I ran into issues when I was trying to get the API to connect from a Docker container to a SQL Server instance I had running locally.

To solve this I created an instance of SQL Server running in it's own container(using the microsoft/mssql-server-linux image).

Both containers are running and are attached to the same user defined bridge network.

If I open a bash terminal in my asp.net core container and run the command:

dotnet ef migrations add InitialMigration

I was hoping that my Code First model would be created in the SQL Server instance running on the network as this is what happens when I run the setup locally (no containers). Instead I get the below:

Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

I am confused because I though dotnet had to be installed. I've used the microsoft/aspnetcore as the base layer in my Dockerfile, and I can see that this in turn uses microsoft/dotnet:1.0.3-runtime as it's base layer...

Can someone explain why I get this message and if I'm approaching this solution in the correct way (web api and sql server in separate containers)? If I do need to install the dotnet sdk, I would appreciate if someone could show me how to do that as part of a Dockerfile

Thanks for any help


Contents of asp.net core Dockerfile

FROM microsoft/aspnetcore:1.1.0
WORKDIR /app
COPY bin/Debug/netcoreapp1.1/publish /app
ENV ASPNETCORE_URLS http://*:3000
EXPOSE 3000

ENTRYPOINT /bin/bash -c "dotnet MyAppName.dll"
1
2
1/12/2017 4:00:54 PM

Popular Answer

microsoft/aspnetcore:1.1.0 your are using is based on microsoft/dotnet:1.1.0-runtime. It contains only .NET Core runtime, not SDK. To execute commands like run, ef and other tools - you need one of sdk-based images

2
1/12/2017 8:58:18 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow