I am having error while connecting to SQL Server:
Details in Stack Trace are:
===================================
Cannot connect to ServerN
You can also get this error, somewhat unhelpfully, if the database name specified in the connection string doesn't exist. Check your Db Name carefully!
SQL 2016 solution/workaround here (could also work in earlier versions). This may not work or be appropriate in every situation, but I resolved the error by granting my database user read/write schema ownership as follows in SSMS:
Database > Security > Users > User > Properties > Owned Schemas > check db_datareader and db_datawriter.