Home  /  Questions  /  Question

50   50
Jul 17, 2015

How to set the connectionstring

I am curious how to setup the connection string in SPARK. I tried..
I'm missing something? pls help

508   99.9
Jul 18, 2015
Hello Archie:

Look at the Art shop example. 

The file Data.cs is where your connection string is specified. 
In the example it is "Art", but you can name it anything you like as along as it matches the connectionstring name in web.config. 

SPARK uses a naming convention.
Suppose your project is named 'Work'. (a short name is best).

  • You will probably have a database named Work.
  • You would have a 'Work' connectionstring name in web.config.
  • Then you will create a WorkDb where you hardcode the "Work" connectionstring name.
  • WorkDb is used by WorkContext, which is then used in your own controller code. 

Essentially replace all instance of the word 'Art' with 'Work' (or whatever your name is. 

Here is your Data.cs file where the connectionstring name is set:
public partial class WorkDb : Db
    public WorkDb() : base("Work") {}

That will take care of it.