izengod
izengod

Reputation: 1156

Npgsql connection string with Entity Framework core

I'm using Npgsql with EF core to establish a connection to PostgreSQL for a demo console application. But I'm getting an exception 'Format of the initialization string does not conform to specification starting at index 0'. I think this because of some issue with the connectionstring. Any help is appreciated.

Exceptionenter image description here

enter image description here

Upvotes: 2

Views: 8204

Answers (1)

izengod
izengod

Reputation: 1156

This should do fine:

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

Upvotes: 6

Related Questions