Connecting to wrong database

2k views Asked by At

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

1

There are 1 answers

3
Luis On BEST ANSWER

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