1

I want to use the SqlEntityConnection type provider in f# to query and update a db.
It works well when I use it with the connection string pointing to a live SQL Server DataBase.

type EntityConnection = SqlEntityConnection<"Data Source=myServer;Initial Catalog=myDb;...", Pluralize=true>

Now I want to get rid of the dependency with the live DB and, instead, use a local schema file. Given what I read on msdn, I gave a try to the following line:

type private EntityConnection = SqlEntityConnection<LocalSchemaFile="mySchemaFile.ssdl", Pluralize=true>

Unfortunately, it doesn't compile and the compiler's message is:

Error 46 The type provider 'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders' reported an error: When using this provider you must specify either a connection string or a connection string name. To specify a connection string, use SqlEntityConnection<"...connection string...">.

So what should I do? If I leave the connection string, I have the feeling that I don't really turn off the dependency to the DB. For instance, if I try to switch the Data Source with a non-existing server, it doesn't compile.

Ruben Bartelink
62.1k32 gold badges194 silver badges266 bronze badges
asked Dec 8, 2014 at 18:50

1 Answer 1

2

You can provide a connection string name, along with a connection string in the configuration file. You can still provide a localschemafile that will be used to cache locally the schema.

If you put the schema file under source control, the connection string will only be used as a default when calling GetDataContext() without parameter, but not when building or editing code.

You also need to set the parameter ForceUpdate to False.

pierroz
7,9309 gold badges52 silver badges60 bronze badges
answered Dec 8, 2014 at 21:00

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.