Matt
Matt

Reputation: 5680

How to Connect to Azure SQL Server?

I am new to the Azure way of doing things but have successfully gotten a DB setup and data to an Azure SQL DB. The problem I'm having is that I cannot connect to the DB via my MVC 4 app. I am using the Entity Framework. My connection string is correct. But I get the following error message:

Format of the initialization string does not conform to specification starting at index 0.

My thinking is that my web.config file is not configured correctly? I am including portions here:

    <configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
  </configSections>
  <connectionStrings>
    <add name="MovieContext" connectionString="Data Source=rh9bqjbkqi.database.windows.net; Initial Catalog=MainSQLDB; User ID=****; Password=****;" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="PreserveLoginUrl" value="true"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    <add key="MvcMailer.BaseURL" value=""/>
  </appSettings>

Further down the line I have the following:

<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
  <parameters>
    <parameter value="v11.0"/>
  </parameters>
</defaultConnectionFactory>

Please advise as I'd like to get around this bump in the road and move on the greater problems, lol.

Upvotes: 1

Views: 388

Answers (1)

greg84
greg84

Reputation: 7629

Try changing it to this:

Server=tcp:rh9bqjbkqi.database.windows.net;Database=MainSQLDB; User ID=username@rh9bqjbkqi;Password=password;Trusted_Connection=False;Encrypt=True;

Upvotes: 1

Related Questions