Sergio Tapia
Sergio Tapia

Reputation: 41128

Using a Linq-To-SQL class automagically generates the connection string for me; is there a way to manually set it?

I'm just beginning to use Linq-to-SQL and it's just wonderful to use. The problem is, this software is going to be run on a lot of machines and each machine will have a unique connection string.

Is there a way for me to manually set the connection the Linq-to-SQL (.dbml) uses?

The way I'm doing things now is creating the .dbml file, and in the graphic designer I'm dragging tables from the Server Explorer to the white board of the .dbml.

Upvotes: 3

Views: 343

Answers (1)

Justin Niessner
Justin Niessner

Reputation: 245399

Yes. Just pass the connection string you want to use to the DataContext constructor:

MyDbContext _context = MyDbContext(connString);

Upvotes: 6

Related Questions