title: Entity Framework with Code First Connection string to a remote database
body: <p>I am working on a local machine (ASP.NET MVC 4 application) but now I want to start using the company's SQL server so I need to change the Connection string in order to connect me to that remote server.</p>
  
  <p>The set up is this:</p>
  
  <ul>
  <li>I have a VPN connection where I use an IP address, can't show the exact IP so let's say - xxx.xxx.xxx.xxx</li>
  <li>I have username and password in order to connect to VPN - VPNUsername/VPNPassword</li>
  <li>When I use <code>Microsoft SQL Server Management Studio</code> to connect to the remote server I use the same IP that I use to connect to the VPN - xxx.xxx.xxx.xxx</li>
  <li>I have different username and password for the SQL Server - SQLUsername/SQLPassword</li>
  </ul>
  
  <p>I have an existing connection string that I use to connect to the server on my PC so I thought it would be enough to just change the parameters there like so :</p>
  
  <pre><code>&lt;add name="ProjectName.DAL.MyDbContext"
       providerName="System.Data.SqlClient"
       connectionString="Data Source=xxx.xxx.xxx.xxx;
       Initial Catalog=DatabaseName;Integrated Security=True;         
       MultipleActiveResultSets=True;
       user id=SQLUsername;password=SQLPassword;App=EntityFramework" /&gt;
  </code></pre>
  
  <p>So the changes from the connection string that works and connects me to my local server are two:</p>
  
  <ol>
  <li><code>Data Source= xxx.xxx.xxx.xxx</code> - I'm using the IP. Here I wonder if the IP itself is sufficinet. Should I use <a href="http://xxx.xxx.xxx.xxx" rel="noreferrer">http://xxx.xxx.xxx.xxx</a> or just IP is ok?</li>
  <li><code>user id=SQLUsername;pasword=SQLPassword</code> - I'm using the same Username and Password as in the <code>Management studio</code> from where I can connect successfully to the remove server by providing the <code>xxx.xxx.xxx.xxx</code> as Server name and using SQLUsername/SQLPassword under <code>SQL Server Authentincation</code>.</li>
  </ol>
  
  <p>So to be clear - under Management Studio I have no problems connecting to the remote server. However, when I change the connection string to what I posted above in my <code>HomeController</code> where I have very simple logic just to check that the call to the database is executed :</p>
  
  <pre><code>private MyDbContext db = new MyDbContext();
  
          //
          // GET: /Home/
  
          public ActionResult Index()
          {
              return View(db.Users.ToList());
          }
  </code></pre>
  
  <p>I get 3 exceptions:</p>
  
  <ol>
  <li>SqlException (0x80131904): Login failed for user 'VPNUsername'</li>
  <li>ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.</li>
  <li>ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string.</li>
  </ol>
  
  <p>So besides that in my opinion and as the number 3 exception tells that the problem is in the way I'm using the connection string what concerns me is also the <code>Number 1</code> exception that says that login is failed but not for my SQLUsername but for the VPNUsername. As I said - I'm really using VPN connection and I use the same IP - <code>xxx.xxx.xxx.xxx</code> to connect both to the VPN and the SQL Server(From Management Studio).</p>
  
  <p>Any idea how to resolve this?</p>