Entity Framework Core - error: keyword not supported: '"server'

11,732

Simple removing \" from front and end of connection string will work. In this case you can use complete connection string.

"DefaultConnection": "\"Server=tcp:myDb.com,1433;Initial Catalog=MyDb;Persist Security Info=False;User ID=admin;Password=Password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"\;"

to

"DefaultConnection": "Server=myDb.com,1433;Initial Catalog=MyDb;Persist Security Info=False;User ID=admin;Password=Password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
Share:
11,732
user1250264
Author by

user1250264

Updated on July 26, 2022

Comments

  • user1250264
    user1250264 almost 2 years

    I am using Entity Framework Core 2.1. I scaffold my entity classes aka database first. When I try to get the data from one of the db tables, I get an error "keyword not supported for 'server'."

    I googled and it looks like my connection string is not correct. Here it is setting in my json file

    "DefaultConnection": "\"Server=myDb.com;Database=MyDb;user id=admin;Password=Password;MultipleActiveResultSets=true;Provider=System.Data.SqlClient"
    

    I have seen other type of EF connection like

    connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=(local);initial catalog=test;integrated security=True;multipleactiveresultsets=True;App=EntityFramework""
    

    I am not sure about the .csdl, ssdl and msl.

    Any help is appreciated. Thanks.

    Error:

    System.ArgumentException: Keyword not supported: '"server'.

    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)
    at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
    at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
    at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
    at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.CreateDbConnection() at Microsoft.EntityFrameworkCore.Internal.LazyRef
    1.get_Value() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext() at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider._TrackEntities[TOut,TIn](IEnumerable1 results, QueryContext queryContext, IList1 entityTrackingInfos, IList1 entityAccessors)+MoveNext() at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor1.EnumeratorExceptionInterceptor.MoveNext() Exception thrown: 'System.ArgumentException' in Microsoft.EntityFrameworkCore.dll 'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.2\System.IO.MemoryMappedFiles.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. The program '[3112] dotnet.exe' has exited with code -1 (0xffffffff).

  • Gert Arnold
    Gert Arnold over 5 years
    It's not clear to me how an incomplete connection string would solve your problem. The part you show is the same as above.
  • jamheadart
    jamheadart over 4 years
    Actually it is slightly different in that the character escapes have been removed. I had the same issue after adding an identity using an existing dbContext and conn string