[英]Stuck on EntityFramework update-database
很多次我都使用entity framework core
和代碼優先遷移,這是我第一次陷入困境。
在我的項目中,一切都在 docker 中運行,我的數據庫也是如此。 我暴露了 1433 端口,所以我可以在外部使用 ssms <- 這很有效,我可以與用戶連接。
當我嘗試更新數據庫來推送我的遷移時,我收到錯誤登錄失敗:container_id\guest。
現在我想知道為什么在連接字符串中指定了 sa 時它會嘗試與 container_id 和來賓用戶連接。 默認項目是我的 API 端點,其中包含我的應用程序上下文 class 以及我的遷移。
問題:有人可以向我解釋我做錯了什么嗎?
version: '3.4'
services:
db:
image: "mcr.microsoft.com/mssql/server:2019-latest"
container_name: MSSQLServer
ports:
- "1433:1433"
environment:
SA_PASSWORD: ${Api_SA_PASSWORD}
ACCEPT_EULA: "Y"
portfolio-frontend:
image: ${DOCKER_REGISTRY-}portfoliofrontend
build:
context: .
dockerfile: Portfolio-frontend/Dockerfile
apiendpoint:
image: ${DOCKER_REGISTRY-}apiendpoint
build:
context: .
dockerfile: HeaderInfoApi/Dockerfile
"ConnectionStrings": {
"ApplicationContext": "Server=server;Database=Portfolio;MultipleActiveResultSets=true;User=username;Password=password"
}
appsettings 中的 connetionstring,在 appsettings.development 中填寫了我真正的秘密,如果我是正確的,應該覆蓋 appsettings。
using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
{
var context = serviceScope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
context.Database.Migrate();
}
我的應用程序構建器中也有這個。
我認為您的連接字符串的Integrated Security=false
部分需要存在。
Data Source=.;Database=myDb;Integrated Security=false;User ID=sa;Password=<password>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.