I have an application written in C# which is currently using a mixture of datasets and some hardcoded SQL statements/stored procedures which uses Advantage Database Server.
I now want my application to also support MS-SQL.
I have a few options :-
1) Branch the source code and manually make the syntactical alterations to enable MS-SQL support. The downside of this is obviously multiple codebases.
2) Move all the DB code into 2 separate libraries (one for ADS, one for MS-SQL) and give the end user the correct library depending on the DB. I am not sure how to set this up, ideally I would like to have both library projects in my VS solution and be able to switch between using them, preferably at debug and run time. Is this possible?
3) Start using a DAL which supports both db backends. If I was to start using EF, would it be possible to generate the schema initially based on the existing ADS database, then switch the connection at run time to a MS-SQL db using the same schema, or would it be better to create two contexts/schemas for each database and somehow switch them at runtime i.e. is it possible to create a method that returns the relevant context via a configuration setting e.g.
dbcontext = new GetDBContext();
DbContext GetDBContext()
{
if( configsetting == "ADS")
return new AdsDBContext();
else
return new MSSQLDBContext();
}
What I want to do is to make incremental changes so the the program continues to run on the existing ADS DB whilst slowly adapting it for MS-SQL/other db backends.
Regards
Mike