PostgreSQL dotnet核心连接字符串

时间:2018-08-01 22:11:47

标签: database postgresql .net-core ef-database-first

我正在尝试使用colling连接字符串连接到postgresql。

dotnet ef dbcontext scaffold "Server=localhost; Port=xxxx; Database=i2ms; User Id=xxx; Password=xxx; SslMode=true" Npgsql.EntityFrameworkCore.PostgreSQL 

我遇到以下错误。

System.ArgumentException: Couldn't set sslmode
Parameter name: sslmode ---> System.ArgumentException: Requested value 'true' was not found.
   at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
   at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
   at Npgsql.NpgsqlConnectionStringBuilder.set_Item(String keyword, Object value) in /home/roji/projects/npgsql/src/Npgsql/NpgsqlConnectionStringBuilder.cs:line 164
   --- End of inner exception stack trace ---
   at Npgsql.NpgsqlConnectionStringBuilder.set_Item(String keyword, Object value) in /home/roji/projects/npgsql/src/Npgsql/NpgsqlConnectionStringBuilder.cs:line 170
   at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
   at Npgsql.NpgsqlConnection.GetPoolAndSettings() in /home/roji/projects/npgsql/src/Npgsql/NpgsqlConnection.cs:line 178
   at Npgsql.EntityFrameworkCore.PostgreSQL.Scaffolding.Internal.NpgsqlDatabaseModelFactory.Create(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas) in /home/roji/projects/EFCore.PG/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseMo
delFactory.cs:line 86
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas, String namespace, String language, String contextDir, String contextName, ModelReverse
EngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
   at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean u
seDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, B
oolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Couldn't set sslmode
Parameter name: sslmode

我的数据库在配置中具有ssl要求。

谢谢。

1 个答案:

答案 0 :(得分:1)

SSL Mode

Possible values是:RequireDisablePrefer。如果您具有自签名证书,则可能要使用Trust Server Certificate=true