实体框架+后GIS GET OMIGRATION失败了错误:28000:角色“ my_username”不存在
我有一个使用以下 docker-compose compose file
version: '3.9'
volumes:
dbbackups:
postgis-data:
services:
db:
image: kartoza/postgis:14-3.2
volumes:
- postgis-data:/var/lib/postgresql
- dbbackups:/backups
environment:
# If you need to create multiple database you can add coma separated databases eg gis,data
- POSTGRES_DB=my_db
- POSTGRES_USER=my_username
- POSTGRES_PASS=my_password
- ALLOW_IP_RANGE=0.0.0.0/0
# Add extensions you need to be enabled by default in the DB. Default are the five specified below
- POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting
ports:
- "25432:5432"
restart: on-failure
healthcheck:
test: "exit 0"
我有一个配置为使用此数据库的ASP.NET Core Web API项目。在 program.cs
中:
builder.Services.AddDbContext<PerceptionAnnotationServerContext>(options =>
options.UseNpgsql("Host=localhost;Port=25432;Database=my_db;Username=my_username;Password=my_password"));
如果我做 get-emigration
或 add-emigration
然后更新数据库
从VS 2022 Pack Manager控制台,我会收到错误:
访问数据库时发生了错误。继续没有数据库提供的信息。错误:28000:角色“ my_username”不存在
我最初发现如何添加用户。但是,使用pgadmin进行检查表明“ my_username”已经存在,并且可以访问“ my_db”。
有什么想法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我忘记了添加到DB上下文中:
I had forgotten to add to the db context: