Search code examples
entity-frameworkdata-access-layerprovider-independent

Entity Framework : Is there any smart way to implement data access so that I can switch web.config settings to switch provider


I want to implement Data Access Layer in Entity Framework in a way that one can switch from excel to sqlite or ms access of ms sql server using a single setting in web.config.

Is there any good suggestion or example for this available?


Solution

  • List of allowed providers for Entity framework is here. As I know Excel and Access are not supported.

    When using EDMX file you must change provider in both connection string and SSDL. SSDL is by default included in assembly as resource so if you want to change provider you must change this behavior and use external SSDL stored in application folder.

    For setting provider for Code-first check this question but be aware that not all features are supported when working with Code-first and DB other then SQL Server or SQL CE.