Question

What is the syntax for defining a SqlDataConnection Type Provider when using a connection string name from an app.config file. I have a solution with two projects in it. The main project is an an mvc 5 project and the second is an F# project. In the f# project I have defined an app.config file with a connection string to a database and defined my SqlDataConnection as this:

SqlDataConnection<ConnectionStringName="dbname", ConfigFile="app.config">

Everything seems to be wired up correctly when writing my f# code, as I am able to get intellisense on the the database tables, but once I run/debug the site I get an error that implies that the data provider is looking for the connection string in the main project. What am I missing here?

Was it helpful?

Solution 2

So it seems that once you run/debug your site, the data provider attempts to look for the connection string in the Web.config of the main project. So I renamed the app.config in my F# project to Web.config, and made sure to have the same connection string listed in the Web.config file of the main project as well. That way I appear to have access to the schema while coding, and when the project runs it picks up the connection string from the main project. This is a working solution for me, but if anyone can shed any more light on this, please do so. The new syntax is:

SqlDataConnection<ConnectionStringName="dbname", ConfigFile="Web.config">

OTHER TIPS

Examples that I've seen all specify a single string to the type provider.

Try:

SqlDataConnection<"ConnectionStringName=dbname;ConfigFile=app.config">

Essentially, this is the same syntax that you'd use in your app.config file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top