Search code examples
c#wcfsql-server-2008service

Mocking / facade for SQL Server with a service?


Is it possible to mock, or create a facade, to replace a SQL Server database in-place, currently being used directly by a website via ADO.net, with a service (ideally WCF or other .NET technology)?

Example:
Consider an ASP.NET website with a lot of features which use SQL Server 2008 over ADO.NET. The SQL transactions involve many stored stored procedures, though there are some direct T-SQL transactions. It would be powerful to be able to replace the (singular) SQL server with a more scalable implementation, without having to re-implement the website features.

This could be a shim for ADO.NET, or an ODBC driver to a custom service framework, or something else. The "right" answer may seem to be "reimplement the website to use a more abstracted data interface", but let's consider that the website code is immutable (though configuration could be altered).


Solution

  • Maybe simply provide an data access layer that specifies well designed interfaces. Your website will only ever have a handle on an interface, and you can use dependency injection/IoC to provide your concrete implementation of your interface on an as needs basis.

    It's not an "existing technology" as such, but probably just a prudent way forward in your design I'd suggest.