postgresql - 具有 Entity Framework 核心的 Npgsql 连接字符串

标签 postgresql entity-framework npgsql

我使用带有 EF 核心的 Npgsql 来建立到 PostgreSQL 的连接以用于演示控制台应用程序。但是我收到一个异常“初始化字符串的格式不符合从索引 0 开始的规范”。我认为这是因为连接字符串存在一些问题。感谢您的帮助。

Exception enter image description here

enter image description here

最佳答案

这应该没问题:

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseNpgsql(@"Server=localhost;Port=5432;Database=dbname;User Id=Id;Password=password");
        base.OnConfiguring(optionsBuilder);
    }

关于postgresql - 具有 Entity Framework 核心的 Npgsql 连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43580445/

相关文章:

linq - Web API、OData、EF5、联合 : The 'Distinct' operation cannot be applied to the collection ResultType of the specified argument

c# - 使用 HasColumnAnnotation 可能有多个索引?

c# - 如何使用 Dapper FluentMap 将 postgresql UUID 解析为 C# 字符串?

c# - 为什么我的必需属性没有在 Entity Framework Core 中级联删除?

sql-server - SQL Server 中 CASE 语句中的 IN 条件

c - postgresql:时区 "localtime"无法识别

php - 让 PHP 读取我的 postgres select 语句?

arrays - array_upper 和 array_length 之间有什么功能上的区别吗?

c# - 使用 XtraGrid Entity Framework 创建主/细节网格

.net - 命令失败后 Npgsql 不提交事务