5

I have an Asp.net MVC5 application and have published it to Microsoft Azure. I first migrated my .mdf files toSql Azure Databases. The database connection string provided in the Azure Portal is not working.

[ArgumentException: Keyword not supported: 'server'.]

My connection string is as follows web.config

connectionString="
    Server=tcp:dbprojectserver.database.windows.net,1433;
    Initial Catalog=db_project;
    Persist Security Info=False;
    User ID=username@servername;
    Password=kenth&&123;
    Encrypt=True;
    TrustServerCertificate=False;
    Connection Timeout=30;
    "

I believe so there is something wrong with this connection string. Any help regarding that is highly appreciated.

EDIT

Reading from here SQL Server Connection Strings and following EF Db first or Model first connection string example

<add name="ConnectionStringName"
    providerName="System.Data.EntityClient"
    connectionString="metadata=res://*/ ContextClass.csdl|res://*/ ContextClass.ssdl|res://*/ ContextClass.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=ServerName;Integrated Security=False;User Id=userid;Password=password;MultipleActiveResultSets=True&quot;" />

This is what I am using according to above example

<add name="ProjectEntities" connectionString="metadata=res://*/ ProjectWeb.Models.User.csdl|res://*/ ProjectWeb.Models.User.ssdl|res://*/ ProjectWeb.Models.User.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=tcp:dbprojectserver.database.windows.net,1433;Integrated Security=False;User Id=username@servername;Password=kenth$$123;MultipleActiveResultSets=True&quot;
      " providerName="System.Data.EntityClient"/>

It says

Keyword not supported 'data source'

Nauman Zafar
  • 1,083
  • 15
  • 40

1 Answers1

5

I had the same problem when specified EF connection string on the Azure Portal in Application Service settings (Application settings -> Connection strings).

To fix it:

  • Replace &quot; with "
  • Specify connection string type as Custom but not as SQL Database.

Also, as I can see you do not have Initial Catalog in your latest example. You need to add it and specify your database in this parameter.

Finally your connection string for application settings in Azure portal should look like this:

metadata=res://*/ ProjectWeb.Models.User.csdl|res://*/ ProjectWeb.Models.User.ssdl|res://*/ ProjectWeb.Models.User.msl;
provider=System.Data.SqlClient;
provider connection string="Data Source=tcp:dbprojectserver.database.windows.net,1433;Initial Catalog=<your database>;Integrated Security=False;User Id=username@servername;Password=kenth$$123;MultipleActiveResultSets=True";
vbuldakov
  • 51
  • 1
  • 4