Page 1 of 1

EF Core 2.1 Keyword not supported: 'license key'.

Posted: Tue 03 Jul 2018 17:21
by dgxhubbard
We setup a connection string as in the code below, then use it to get the data source using a connection string builder.
When the string builder is create an exception is thrown saying "Keyword not support 'license key'. Are we doing something wrong?

Refer to:
https://www.devart.com/dotconnect/sqlit ... ndard.html

I know you can set the license key once one connection is opened in an app domain the license key is not checked again, however we are using three DBMS so we include the license key at all times where it is needed.

Exception:

at System.Data.SqlClient.SqlConnectionStringBuilder.GetIndex(String keyword)
at System.Data.SqlClient.SqlConnectionStringBuilder.set_Item(String keyword, Object value)
at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
at System.Data.SqlClient.SqlConnectionStringBuilder..ctor(String connectionString)

Code:

Code: Select all

var connStr = "Data Source=C:\Repository\GtNext\AppFiles\GtSamp820.db3;Password=we092uRc1SLKr;Persist Security Info=False;License Key=\"NotIncluded\"";

var bldr = new SqlConnectionStringBuilder ( connection.ConnectionString );

var databaseName = bldr.DataSource;



Re: EF Core 2.1 Keyword not supported: 'license key'.

Posted: Wed 04 Jul 2018 11:37
by Shalex
Your stack trace includes a different provider, it should be Devart.Data.SQLite instead of System.Data.SqlClient.

Try using Devart.Data.SQLite.SQLiteConnectionStringBuilder instead of System.Data.SqlClient.SqlConnectionStringBuilder in your code.

Re: EF Core 2.1 Keyword not supported: 'license key'.

Posted: Wed 04 Jul 2018 15:44
by dgxhubbard
Thanks shalex. I didn't even notice that

Re: EF Core 2.1 Keyword not supported: 'license key'.

Posted: Fri 07 May 2021 10:30
by Shalex
IseyGarfield wrote: Thu 06 May 2021 13:35 ello.
I want to select entites with Linq to Entites applying among others a filter by parsed int (if entitie's string feild was parseable to int):
CODE: SELECT ALL

Int32 CodeAsInt = Int32.MinValue;
var result = MyDBContext.MyEntites.Where(e => (e.Name == "test") &&
(Int32.TryParse(e.StringCode, out CodeAsInt)) && (CodeAsInt == 333)).Tolist()
The code above fails because Linq to Entites doesn't support Int32.TryParse method.
The only workaround for now is to switch from Linq to Entites to Linq to Objects via .AsEnumerable() method:
CODE: SELECT ALL

Int32 CodeAsInt = Int32.MinValue;
var result = MyDBContext.MyEntites.Where(e => (e.Name == "test")).AsEnumerable().
Where(e => (Int32.TryParse(e.StringCode, out CodeAsInt)) && (CodeAsInt == 333)).Tolist()
But that approach is ugly and slow (because .AsEnumerable() loads data from database to memory - and amount of that data is significantly more that I really need).

In EF provider for SQL Server (System.Data.Objects.SqlClient) there is special helper class SqlFunctions which among others contains IsNumeric method (which succesfully can be used inside Linq to Entites).

Is there some similar function in Devart DotConnect for SLite?
If no - is there some other workaround, without using .AsEnumerable()?
This question was discussed at viewtopic.php?t=37332.