简体   繁体   中英

Entity framework 7 with Microsoft SQL server not working in Docker

I am using EntityFramework 7 with Microsoft SQL server in asp.net 5. I am using EntityFramework.MicrosoftSqlServer: 7.0.0-rc1-final. When I run my web application in visual studio everything it works as expected. But, I want to run my application in Docker. I am using official Docker image for running asp.net application: microsoft/aspnet:1.0.0-rc1-update1-coreclr

Here is my dockerfile:

FROM microsoft/aspnet:1.0.0-rc1-update1-coreclr

COPY project.json /app/

WORKDIR /app

RUN ["dnu", "restore"]

COPY . /app

ARG CONTAINER_PORT=5000

ARG SERVER_URLS=http://*:$CONTAINER_PORT

ENV SERVER.URLS $SERVER_URLS

EXPOSE $CONTAINER_PORT

ENTRYPOINT ["dnx", "-p", "project.json", "web"]

Build is successful in docker, but when I run application I get following error after application starts:

Application startup exception: System.IO.FileLoadException: Could not load file or assembly 'app, Culture=neutral, PublicKeyToken=null' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500) [36mwebapi_1 | [0mFile name: 'app, Culture=neutral, PublicKeyToken=null' ---> Microsoft.Dnx.Compilation.CSharp.RoslynCompilationException: /app/Startup.cs(33,18): DNXCore,Version=v5.0 error CS1061: 'EntityFrameworkServicesBuilder' does not contain a definition for 'AddSqlServer' and no extension method 'AddSqlServer' accepting a first argument of type 'EntityFrameworkServicesBuilder' could be found (are you missing a using directive or an assembly reference?)

The problem seems to be in 'AddSqlServer' command. Strange thing is that it works when built and runt from visual studio. Does anyone know something about this problem?

Thanks.

Try explicitly sharing your drive with the Docker host. If you are using docker-machine, this is under the settings for default in Virtual Box. If you have the Docker for Windows beta, you can do it in the settings from the task bar icon. It may not be that the extension method is missing, only that Docker can't access it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM