Wednesday, June 19, 2013

SQL Server Compact Code Snippet of the Week #16 : detect Entity Framework database type

This weeks code snippet is prompted by a StackOverflow question, regarding how to detect if the database that was backing an Entity Framework DbContext was SQL Server Compact.

My proposed check simply uses the "is" operator to determine if the Database.Connection property is compatible with the SqlCeConnection class.

so my check is:

context.Database.Connection is SqlCeConnection

No comments: