0

I'm using entity Framework 6 DBContext , Database First.

I have created the Model using wizard form an existing SQL server database. Now on the app.config file , this connection string :

    <connectionStrings>

<add name="MyEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|    res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=My_PC;initial catalog=MyDatabase;integrated     security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

</connectionStrings>

This is working on a PC with SQL server installed. But if I try on a pc with SQL server Express , this is not working ( of course I have changed in the connection string the PC name. The database name is the same ).

What should I change in the above connection string in order to make it work on a SQL server express ?

My goal is to make this programmatically , so when my application is start , to test if is a SQL server or SQL server express environment and to make the changes on the app.config file .

Thank you !

7
  • I believe the SQL Express installation configures a "named instance" of SQL Express. Take a look at this answer. You will probably want to set the data source to localhost\SQLExpress or the equivalent. Commented Aug 12, 2015 at 13:40
  • this is not working nah, I believe it's working. You claim it isn't working, yet you don't say how, nor do you have any exception details, etc in your question. I think that makes you a liar. Or, you can edit, add those details, and make me the liar. Seriously, tho, @DanielPratt is probably correct. Commented Aug 12, 2015 at 13:41
  • @Will : If I use the same connection string as above , on a PC with sql server express installed , the application became busy (as if is searching for something ) and after stop responding. So I have no exception details to add on my question. Commented Aug 12, 2015 at 13:50
  • Just hangs? Gotta time out eventually, which results in an error. Always. Tools such as Profiler can also help. Configure it to watch the express server, then watch as your app attempts to connect. Commented Aug 12, 2015 at 15:31
  • @Will : This is the error message : “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) ” Commented Aug 12, 2015 at 15:38

0

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.