How to set a proper connection string for Azure database?

爱⌒轻易说出口 提交于 2019-12-11 00:29:14

问题


I have an azure website and database. I'm running an ASP.NET MVC 4 / EF 5 app localy and trying to put some data to the azure database before to deploy the app. But I have a TargetInvocationException : {"The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588"} Keyword not supported : server

This is the connection string that I get from my azure dashboard :

    <add name="myconstring" connectionString=Server=tcp:myserver.database.windows.net,1433;Database=mydatabase;User ID=cdptest@myserver;Password=******;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.EntityClient" />

I tried this I got "Keyword not supported : data source"

    <add name="myconstring" connectionString="Data Source=myserver.database.windows.net;Initilal Catalog=mydatabase;User ID=cdptest@myserver;Password=*****;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.EntityClient"/>

回答1:


The following works for me:

 <add name="coupdpoAPEkowswAEntities" connectionString="Server=tcp:myserver.database.windows.net,1433;Database=mydatabase;User ID=cdptest@myserver;Password=*****;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.EntityClient"/>

Use Server instead of Data Source, and specify the protocol and the port, and use Database instead of Initial Catalog




回答2:


OK the providername was wrong. System.Data.SqlClient was excepted as this is a code first app model. I probably got System.Data.EntityClient from another app with Model First or Database First...



来源:https://stackoverflow.com/questions/26017705/how-to-set-a-proper-connection-string-for-azure-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!