question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.

See original GitHub issue

System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0. at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary2 parsetable, String connectionString, Boolean buildChain, Dictionary2 synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions…ctor(String connectionString, Dictionary`2 synonyms, Boolean useOdbcRules) at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value) at Npgsql.NpgsqlConnectionStringBuilder…ctor(String connectionString) at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.Exists() at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists() at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) Format of the initialization string does not conform to specification starting at index 0.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rojicommented, Apr 9, 2020

The value with the special character needs to be quoted, i.e. Server=localhost;Port=5432;Database=testdb;User Id=user;Password="password'".

0reactions
dvdvardanyancommented, Apr 9, 2020

I get similar error message when password starts or ends with a single quote. Then it fails on object init (when single quote is in the middle of the text it parses without errors):

NpgsqlConnection con = new NpgsqlConnection(connection.ConnectionString);

with the following error message:

Format of the initialization string does not conform to specification starting at index 56.

at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary2 parsetable, String connectionString, Boolean buildChain, Dictionary2 synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary2 synonyms, Boolean useOdbcRules) at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value) at Npgsql.NpgsqlConnectionStringBuilder…ctor(String connectionString) at Npgsql.NpgsqlConnection.GetPoolAndSettings() at Npgsql.NpgsqlConnection.set_ConnectionString(String value) at Npgsql.NpgsqlConnection…ctor(String connectionString) at Persistence.PostgreSql.DataAccess.PostgreSqlConnection.<TestConnectionAsync>d__0.MoveNext() in D:\…\src\Infras…`

Failing connection strings:

Server=localhost;Port=5432;Database=testdb;User Id=user;Password=password’; Server=localhost;Port=5432;Database=testdb;User Id=user;Password='password;

Package reference:

<PackageReference Include=“Npgsql” Version=“4.1.3” />`

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Format of the initialization string does not conform to ...
Check my answer on this post: How to fix error ::Format of the initialization string does not conform to specification starting at index...
Read more >
Facing error : Format of the initialization string does not ...
This problem is usually caused by the connection string containing extra single quotes and double quotes. Please check the connection string in ...
Read more >
[Solved] Format of the initialization string does not conform ...
Solution 1​​ You have a typo in your connection string property. In the string below you have nitial Catalog, but it should be...
Read more >
Format of the Initialization String Does Not Conform to ...
You can fix the format of the initialization string by checking the connection strings for typos and adjusting the broken values. For example,...
Read more >
System.ArgumentException:'Format of the initialization string ...
System. ArgumentException : ' Format of the initialization string does not conform to specification starting at index 60.' System.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found