Jake
Jake

Reputation: 1332

LinqToSql use appsettings instead of connectionString

I have an application that uses LinqToSql, the problem came when I tried deploying the application to the server. The team uses a machin.config file to store the connection string for all apps on the server. After I stored my connection string in that file and use my application appsettings node in my web.config to reference that connectionstring is where the problem comes in. LinqToSql automatically autogenerates a connectionstring, so it tries to still use the connection string I am trying to reference to instead of letting me use the reference by my appsettings.It also has the connectionstring in the .dbml linq to sql file. Has anyone ever ran into this problem before?

Upvotes: 0

Views: 345

Answers (2)

Jake
Jake

Reputation: 1332

I had to change the properties of my .dbml file on appsettings to False and clear out the connectionstring in the properties, Save then I had to recrete my default constructor to use the appsettings value in my webconfig instead of using a connectionstring

Upvotes: 0

Pleun
Pleun

Reputation: 8920

You can provide a connectionstring when creating a DC

new DataContext ("cxstring") 

So if you have a DC factory you can get the connectionstring from the machine config

Upvotes: 2

Related Questions