ObjectContextManager<T>.GetManager suggestion

ObjectContextManager<T>.GetManager suggestion

Old forum URL: forums.lhotka.net/forums/t/9349.aspx


brianlagunas posted on Tuesday, August 10, 2010

I would like to suggest that you provide an overload for the GetManager methos that takes an Entity connection string.

When dealing with large databases, 100 tables plus, it is common practice to create seperate entity data models for the same database. Similar to database schemas.  When I do this I like to dynamically create my connection strings at runtime, depending on a number of factors including if it is test/dev/prod.

Example:  

 public static string GetConnectionString()
{
     return new EntityConnectionStringBuilder()
     {
         
Provider = "System.Data.SqlClient",
          Metadata =
"res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl",
          ProviderConnectionString =
new SqlConnectionStringBuilder()
          {
              
DataSource = "server",
               InitialCatalog =
"database",
               UserID =
"user",
               Password =
"password"
          
}.ConnectionString
     }.ConnectionString;
}

Now it would be greate to have an overloaded GetManager method that takes that connection string:

ObjectContextManager<T>.GetManager(GetConnectionString());

This helps keep the framework flexible by not forcing the connection string to be in the app.config.

 

RockfordLhotka replied on Tuesday, August 10, 2010

That already exists:

GetManager("your connection string", false)

 

brianlagunas replied on Tuesday, August 10, 2010

Oh, sorry about this misunderstanding.  I misunderstood what the isDatabaseName parameter did.  I thought it was related to allowing mutliple connections open at once, but that must be the label parameter.  Thanks for the clarification.

Copyright (c) Marimer LLC