Changing Database in Generated Code

Posts   
 
    
BarbC
User
Posts: 10
Joined: 01-Jun-2016
# Posted on: 01-Jun-2016 22:36:39   

I am a LLBLGEN Pro user, Version 2.6. I want to prefix this by saying I didn't develop the code I'm working with - I just support it so I don't know all the ins and outs.

We recently changed the name of our Database and when I tried to re-generate my C# windows solution - it gave me runtime errors, since it was prefixing the database name on the tables.

I searched on the Internet and found directions for updating the LLBLGEN config file to override this and I added the following tags:

<configuration> <configSections> <!-- The GraphLib configuration settings for the Netron graph library --> <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler" /> <section name="GraphLibs" type="Netron.GraphLib.Configuration.GraphLibConfigurationHandler,NetronGraphLib"/> </configSections> <sqlServerCatalogNameOverwrites> <add key="LMDB" value="" /> </sqlServerCatalogNameOverwrites>

Basically I want to rename the LMDB catalog name with "" so that it will work with my new name and the name (which will be different) when I move to production.

I re-generated my code, but I am still seeing the same error when I execute the code.

What am I missing?

Thanks

Barb

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 02-Jun-2016 18:53:28   

If you leave the new catalog name empty, then it will use the Catalog/Database name in the ConnectionString.

Are you using the correct connectionString?

Btw, these configurations should be in the application config file. So if you are building a web application, then it should be in the web.config, otherwise app.config for the client executable application.

BarbC
User
Posts: 10
Joined: 01-Jun-2016
# Posted on: 02-Jun-2016 19:31:28   

I'm confused. I thought the issue was that LLBLGEN is generating my code with the database name as a prefix on all tables. Or ... is this happening in my application where I'm using it?

It is a Windows App, and I have an App.Config file. My configuration string is correct in the App.Config file so it seems like what I'm doing is right.

The XML that I pasted in the initial post was in the .config file for LLBLGEN.. I thought it needed that to generate the code. Did I put the XML tags in the wrong config file?

Sorry for my confusion... I'm learning..

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 02-Jun-2016 20:16:00   

You need this configuration in the app config file. Yes the code has the development database/catalog name, but you can instruct the LLBLGen libraries to ignore it and use the one you assign in the config file, or just use whatever is passed in the connection string.

Ref: Catalog Name Overwrites