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?
1 Answer 1
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()
Explore related questions
See similar questions with these tags.
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.