Switching Between Databases with Different Name

Posts   
 
    
Posts: 2
Joined: 08-Aug-2009
# Posted on: 28-Nov-2009 20:23:04   

I have two database server once that points to the development server called databaseDEV and one that points to the production server called DatabasePro when I generate the code against the development server I notice that the actionstoredprocedure class includes the database name, is it possible to swtich between database that have the same structure but different names once the code is generated without regenerating the code.

Also is it possible to change the database name or connection string in an existing project file currently I have to maintain two LLBLGen project files one for test database and one for Production database I would like to be able to change the connection string and point to another database and just refresh the project.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Nov-2009 18:24:55   

Hi Melvin,

Sure. You can change your connection string to wherever your DB is. In the case of the database name, you should use Catalog name overwrite. So in your case it should look like:

<configSections>
    <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler" />
</configSections>
...
<sqlServerCatalogNameOverwrites>
    <add key="databaseDEV" value="DatabasePro " />
</sqlServerCatalogNameOverwrites>

This makes sure that at runtime any reference in the persistence info of the elements in the generated code to the catalog 'databaseDEV' is renamed to 'DatabasePro '.

You can also specify an empty string as new name. In that case, the DQE will not specify a catalog name in the generated SQL elements, which will make the SQL target the catalog specified in the connection string. For example:

<appSettings>
        <add key="Main.ConnectionString" value="data source=myServer;initial catalog= databaseDEV;..."/>
</appSettings>
...
<sqlServerCatalogNameOverwrites>
    <add key="databaseDEV" value="" />
</sqlServerCatalogNameOverwrites>

That all. You don't need to have two different LLBLGen projects wink

David Elizondo | LLBLGen Support Team
Posts: 2
Joined: 08-Aug-2009
# Posted on: 30-Nov-2009 07:11:22   

Sounds Great What File am I placing these changes in

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 30-Nov-2009 08:43:50   

The configuration file of your application. "Web.Config" in case of a web app, or the applicationName.exe.config in case of a win app.