Visual Studio/C# Entity Data Model
I setup a EDM for a SQL database in visual studio. I set the connection string in a configuration file but my question is how I can test if the database was properly connected.
If I put a broken connection string for the database in the config file, the program still boots and makes its way 开发者_运维知识库to the queries, then it throws an exception. How can I ensure that the string has made a successful connection or not?
Thanks
Make a call to check if the DataBase exists
using (var ctx = new BonsaiEntities())
{
if ( ctx.DatabaseExists() ) {
};
}
精彩评论