I was wondering if it is possible to connect a local database to a web application published on Azure.
Currently, I have modified my connection string by changing the instance name to the public IP provided by myip.opendns.com and adding port 1433 to the specification.
<add name="DB"
connectionString="metadata=res://*/Models.CNL.csdl|res://*/Models.CNL.ssdl|res://*/Models.CNL.msl;provider=System.Data.SqlClient;provider connection string="data source={myip},1433;initial catalog=cnl;persist security info=True;user id=sa;password=1234;multipleactiveresultsets=True;application name=EntityFramework;Connect Timeout=60;""
providerName="System.Data.EntityClient" />
It throws the error "The wait operation timed out," and if I remove the port specification, it says "Access is denied." I have the inbound rule for port 1433, as well as the option to allow remote connections in SQL. If I leave the same name as my local instance, "server\SQLEXPRESS," it throws an error stating that the instance cannot be found; and if I use the local IP address of my computer directly and handle it the same way as in the cases of using the public one, it throws the same errors.
1条答案
按热度按时间vhmi4jdf1#
The EntityClient provider is used for accessing data based on an Entity Data Model (EDM). Unlike the other .NET Framework data providers, it does not interact directly with a data source. Instead, it uses Entity SQL to communicate with the underlying data provider. The EntityClient provider exposes generic interfaces for client code and acts as a bridge to other .NET Framework data providers, such as System.Data.SqlClient. If you have to use EntityClient directly, it is easy to code against because it follows the familiar programming patterns found in the other .NET Framework data providers
I used this reference DOC , to connect to an Azure SQL server using
System.Data.EntityClient
.data source=YourServerName
andinitial catalog=YourDatabaseName
.Azure: