I added two EDMs to my project, one for each database. I modified the ObjectContext class to accept different contexts, i.e.:
public class TestContext : ObjectContext
{
public TestContext(string contextName) : base("name=" + contextName, contextName)
{
_projects = CreateObjectSet<Project>();
}
public ObjectSet<Project> Projects
{
get
{
return _projects;
}
}
private ObjectSet<Project> _projects;
}
After that, I can now connect to either database by specifying either:
var compactContext = new TestContext("CompactEntities");
OR
var context = new TestContext("Entities");
Now I can use the same class files to both databases, and sync up the data in both with quite easily. The only redundancy is the EDMs, but since they are generated by Visual Studio, I don't care.
All too easy.
No comments:
Post a Comment