I have two Context as you see below.
public class AddressContext:DbContext{
public AddressContext()
{
Name = "AddressContext";
}
public DbSet<address> addresses { get; set; }
}
public class NamesContext:DbContext{
public NamesContext()
{
Name = "NamesContext";
}
public DbSet<Names> names { get; set; }
}
I also added enum
for DatabaseType
.
public enum DatabaseType
{
address,
names
}
I would like to get Context
based on DatabaseType
.
I am not very familiar with the Factory or Strategy pattern in C#. I did try to write it but at the end I have to cast that context in order to use it.
What is the best way to get Context
based on passing DatabaseType
as parameter?