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?

user1206480
  • 1,798
  • 3
  • 28
  • 45
  • 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. – rmunn May 11 '17 at 08: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. – user1206480 May 11 '17 at 13:40

1 Answers1

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()
user1206480
  • 1,798
  • 3
  • 28
  • 45