Cannot connect to DB with EF4.1 (CodeFirst) using RIAServices RRS feed

  • Question

  • I'm having problems connecting to my existing database when I'm using Entity Framework 4.1 (CodeFirst) with RIAServices. I followed the instructions on this blog post: http://varunpuranik.wordpress.com/2011/06/29/wcf-ria-services-support-for-ef-4-1-and-ef-code-first/. I've created my model and DbDomainService and everything seems to be fine but itsn't. 

    First I got a build error stating: "Failed to get the MetadataWorkspace for the DbContext type <MYTYPE>".

    After doing some Googling, I found out that it's something to do with the ConnectionString of the Context. I added this to the constructor of my context.

    Database.Connection.ConnectionString = <MYCONNECTIONSTRING>

    After this the solution was built successfully. I'm sure that the connectionstring is correct but I'm getting a connection error in runtime stating:

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

    Any ideas?

    Tuesday, September 27, 2011 4:07 AM


All replies