How do I set an ADO.NET Entity Framework connection string via the Windows Azure (Preview) Management Portal?

前端 未结 5 1741
一向
一向 2020-12-16 10:53

In the Windows Azure (Preview) Management Portal you can change the configuration options for web sites (see http://www.windowsazure.com/en-us/manage/services/web-sites/how-

相关标签:
5条回答
  • 2020-12-16 11:17

    The solution for my problem was selecting "Custom" instead of "SQL Azure" from the "SQL Azure / SQL Server / MySQL / Custom" selector for the Entity Framework connection string, even though the database does run on SQL Azure.

    [Edit] From a popular comment by @matthew-steeples below:

    I would add to this for anyone else having the same issue is that sometimes the config file will have " instead of ", and the Azure Websites needs those to be changed to "

    0 讨论(0)
  • 2020-12-16 11:19

    Beside answers above, there are 2 very important things:

    1. You should remove "name=" from "name=connectionString" in constructor:

    public MyEntities(string connectionString) : base($"name={connectionString}") { }

    1. You should leave "duplicate" of connection string in app.config, but replace connection string with dummy text, correct connection string will be loaded from Azure. That's needed for providerName part. Please read: https://mohitgoyal.co/2017/07/05/update-connection-string-for-entity-framework-in-azure-web-app-settings/comment-page-1/
    0 讨论(0)
  • 2020-12-16 11:22

    Not only did I have to use double quotes (or single quotes) instead of " (and select Custom for the type) but I also had to make sure there was a dummy value in my transform config. I was replacing the entire connectionStrings node, but decided to keep that and add this:

    <add xdt:Transform="Replace" xdt:Locator="Match(name)" name="FooBarEntities" connectionString="temp" providerName="System.Data.EntityClient" />
    

    Without this, I was getting the following error:

    The connection string 'FooBarEntities' in the application's configuration file does not contain the required providerName attribute.

    0 讨论(0)
  • 2020-12-16 11:28

    I had the same problem. I solved, putting in the web.config this connectionstring:

    <add name="eManagerTurModelConnection" connectionString="metadata=res://*/ORM.eManagerFinanceModel.csdl|res://*/ORM.eManagerFinanceModel.ssdl|res://*/ORM.eManagerFinanceModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=<server>.database.windows.net;Initial Catalog=eManagerTur;Integrated Security=False;User ID=<user>;Password=<Password>;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    

    And after I removed the connectionstring of my website, worked, because it was not getting the connection string that I added in my web.config.

    English bad... =)

    0 讨论(0)
  • 2020-12-16 11:37

    Replace

    &quot;
    

    with

    "
    

    In the connection string.

    0 讨论(0)
提交回复
热议问题