2

Is it possible to connect to Sql Azure with Entity Framework "Code First" ctp 5? I keep getting a:

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible." ..message.

I know my connection string is correct because I can connect to the database with server explorer in Visual Studio.

I tried connecting to an existing database and creating a database first, both return the same message.

Also, everything works if I use a local database (sqlexpress).

0

3 Answers 3

2

I was passing the name of the connection string into the constructor instead of the connection string name. If you do this, I think it automatically creates a new sqlExpress connection. This may be because I placed the connection strings in the web.debug.config and web.live.config and it couldn't resolve them.

Sign up to request clarification or add additional context in comments.

Comments

0

SQL Azure does not support (or to be more precise give access to) all of the system stored procs and other commands that regular SQL server or SQL Express support and open up to. You will find SQL Azure somewhat constraining when it comes time to managing it.

What you want to do is create your database locally and then migrate it over to SQL Azure using either RedGate's SQL Compare beta for version 9.0 found at: http://www.red-gate.com/Azure or use SQL Azure migration wizard found at: http://sqlazuremw.codeplex.com/

1 Comment

Thanks, but migration is not a problem. I can create the database on azure and connect to it - I just can't connect to it using EF Code first (cpt5).
0

I'm having the same problem, not connecting to azure though. This question came up in my search. I have code first working fine with my local SQLExpress instance but when I try and connect remotely to another server running SQL2008R2, I get the same error. I can however, in the same code I'm using CF CTP5, connect with the same ConnectionString using straight ADO.NET.

2 Comments

I finally got this working, try passing the ConnectionString in the DbContext constructor instead of the name of the ConnectionString in the .config file.
I'm incorrect, it resolves the ConnStr by name fine, I had a mismatch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.