Roswell
Roswell

Reputation: 1

SubSonic 3.0 two different Databases namespace Issue

My question is simple, I have two databases with the same scehema, one is live database say DLive and other one is testbed say DTestBed....

However, I want to use the same database namespace for both database. How can I achieve that without changing namespace in my code all over? Sometimes you need to do builds for live and testbeds in the same day ! Its really hard to change big project namespaces everytime you build.

How can I just change the webconfig connection string and get it done?

Thanks,

Upvotes: 0

Views: 209

Answers (2)

Naeem
Naeem

Reputation: 31

STEP 1: Open 'Setting.ttinclude' from your Subsonic project..

STEP 2: Add new vairable beneath 'const string DatabaseName'..

const string DatabaseObjectName = "DatabaseObjectName";// This is the object that you use for calling Stored Procedures, Tables and etc... 

like this; DatabaseObjectNameDB db = new DatabaseObjectNameDB();

STEP 3: Now open 'ActiveRecord.tt', 'StoredProcedures.tt', 'Context.tt' files from your Subsonic project..

STEP 4: Replace '<#=DatabaseName#>' with '<#=DatabaseObjectName#>' in above opened files...

STEP 5: Now 'Run Custom Tools', by Righ-Click your Subsonic project...

Here you go... Problem solved!!

Regards, Naeem

Upvotes: 3

J&#252;rgen Steinblock
J&#252;rgen Steinblock

Reputation: 31723

Are you using SubSonic2 or three?

With SubSonic 3 it's as simple as this:

var db = new YourProductDB("connectionstringname");
var db = new YourProductDB("Server=localhost;Database=devdb;Uid=root;", "MySql.Data.MySqlClient");

for the first row you have to have both connection strings defined in your web.config/app.config

Upvotes: 0

Related Questions