[英]Stuck on EntityFramework update-database
For a ton of times I have used entity framework core
and code-first migrations it's the first time I'm stuck.很多次我都使用entity framework core
和代码优先迁移,这是我第一次陷入困境。
In my project, everything is running in docker so is my database.在我的项目中,一切都在 docker 中运行,我的数据库也是如此。 I exposed port 1433 so I was able to externally use ssms <- this works i can connect with a user.我暴露了 1433 端口,所以我可以在外部使用 ssms <- 这很有效,我可以与用户连接。
When I try to do update-database to push my migrations I got the error login failed: container_id\guest.当我尝试更新数据库来推送我的迁移时,我收到错误登录失败:container_id\guest。
Now I'm wondering why it tries to connect with container_id and guest user while sa is specified in the connectionstring.现在我想知道为什么在连接字符串中指定了 sa 时它会尝试与 container_id 和来宾用户连接。 The default project is my API endpoint which contains my application context class as well as my migrations.默认项目是我的 API 端点,其中包含我的应用程序上下文 class 以及我的迁移。
question: Can someone explain to me what i'm doing wrong?问题:有人可以向我解释我做错了什么吗?
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"
} }
connetionstring in appsettings, in appsettings.development my real secrets are filled in which should override appsettings if i'm correct. appsettings 中的 connetionstring,在 appsettings.development 中填写了我真正的秘密,如果我是正确的,应该覆盖 appsettings。
using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
{
var context = serviceScope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
context.Database.Migrate();
}
I also have this in my application builder.我的应用程序构建器中也有这个。
I think it's the Integrated Security=false
part of your connection string that needs to be there.我认为您的连接字符串的Integrated Security=false
部分需要存在。
Data Source=.;Database=myDb;Integrated Security=false;User ID=sa;Password=<password>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.