1

Environment .NET 3.5 Self Servicing LLBL Pro 2.6

I know I might be doing something stupid here. I have following code

string connectionString = ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString;
        DbUtils.ActualConnectionString = connectionString;


        PersonCollection ps = new PersonCollection();
        ps.GetMulti(new PredicateExpression(Person.Lastname == "lastname" ));
        Console.WriteLine(pt.Count);

Now when I generated the entities from LLBL Studio, I used a db named ForGeneratingLLBL but in app.config connection string is pointing to another db Master . My expection is that program will retrieve data from whatever is defined in DbUtils.ActualConnectionString (which in this case is defined in app.config) but for some reason its still retreiving data from ForGeneratingLLBL. Any idea what i am doing wrong here?

PS: I have posted this quetion on LLBL forum as well, trying here to see if anyone had similar issue before

imak
  • 6,489
  • 7
  • 50
  • 73
  • 1
    This is one of the LLBLGen gotchas...why do they hardcode the db name in the generated entities? not sure, performance or security... definitely not intuitiveness...have tried lots of other ORMS and never came across anything like this. – Luis Feb 03 '11 at 16:02

1 Answers1

2

If your DB is different than the one you generated the entities you need to put this in your config file:

<configuration>
  <configSections>
    <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler"/>
  </configSections>
</configuration>

and this:

<sqlServerCatalogNameOverwrites>    
    <add key="OriginalDatabase" value="TargetDatabase" />
  </sqlServerCatalogNameOverwrites>

In the documentation, under Catalog name overwriting

Luis
  • 5,979
  • 2
  • 31
  • 51
  • 1
    i am doing something similar ( little different) but let me make sure i understand it. So from my example, should i have ? – imak Feb 03 '11 at 16:04
  • 1
    ok so i used the example i provided above and it worked fine but this mean that I will have to provide this target db name twice one under sqlServerCatalogNameOverwrites and then also under connectionStrings, correct? – imak Feb 03 '11 at 16:07
  • 2
    actually just setting the original db name to empty string work too. – imak Feb 03 '11 at 16:35