2

I am building an Asp.net Core (.NET Framework 4.6.2) project. I added a referenced F# project that uses FSharp.Sql.DataClient. When I call the F# code from the main project to retrieve data from the database I get this error:

Keyword not supported: 'name'

This worked perfectly in projects before Asp.net Core, so I am guessing this may have something to do with how the connection strings are defined in the appsettings.json file in the main project, opposed to a config file in previous versions, and in the config file within the referenced F# project. My sql code is defined like this:

type Select_AllTags =
 SqlCommandProvider<
 "
 select * from article.article_Tag
 ", Admin.connectionName, ConfigFile = Admin.configFile
 >

called later in the code like this:

Select_AllTags.Create(Admin.connectionString).Execute()

How can I make this work with Asp.net Core?

asked May 11, 2017 at 6:14
2
  • Your question is missing a few key things for anyone to be able to answer you. For example, the error message you're getting mentions an unsupported keyword that appears nowhere in the code you're posted. Since we don't know where you're using name (it certainly doesn't appear in the code you're posted so far), there's no way we'll be able to help you figure this out. We need to see more of your code before anyone will be able to answer your question. Commented May 11, 2017 at 8:44
  • 'name' is the keyword that refers to the name of the the connection string defined in the config file. So Admin.connectionName is the string "name=DatabaseName", and Admin.configFile is the string referring to the name of the config file such as "web.config". So when the app is runs, as the error states, I'm assuming that you can no longer access the connection string in the project.json file by name. Commented May 11, 2017 at 13:40

1 Answer 1

0

For what ever reason my initial code worked in previous DotNet Core apps, but now I must call the actual connection string when calling the code at run time. So here is the updated code:

let connectionName = "ManagementDb"
let configFile = "web.config"
let runtimeConnectionString = Config.ConnectionStrings.ArticleManagementDb //Using FSharp.Configuration here to grab the connection string
type Select_AllTags =
SqlCommandProvider<
 "
 select * from article.article_Tag
 ", connectionName, ConfigFile = configFile
 >
Select_AllTags.Create(runtimeConnectionString).Execute()
answered May 13, 2017 at 21:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.