具有 Entity Framework 核心的 Npgsql 连接字符串
Npgsql connection string with Entity Framework core
我使用带有 EF 核心的 Npgsql 来建立到 PostgreSQL 的连接以用于演示控制台应用程序。但是我遇到了一个例外 'Format of the initialization string does not conform to specification starting at index 0'。我认为这是因为连接字符串存在一些问题。感谢任何帮助。
这应该没问题:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(@"Server=localhost;Port=5432;Database=dbname;User Id=Id;Password=password");
base.OnConfiguring(optionsBuilder);
}
我使用带有 EF 核心的 Npgsql 来建立到 PostgreSQL 的连接以用于演示控制台应用程序。但是我遇到了一个例外 'Format of the initialization string does not conform to specification starting at index 0'。我认为这是因为连接字符串存在一些问题。感谢任何帮助。
这应该没问题:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(@"Server=localhost;Port=5432;Database=dbname;User Id=Id;Password=password");
base.OnConfiguring(optionsBuilder);
}