3

My project has an Entity Framework connection string but I want to connect to a SQL Server Express database, so I think I have to change the connection string to SQL Server Express - but how ?

I want to change below connection string. Is it also enough connect database just changing connection string for same SQL Server mdf file ?

<add name="MyEntities"
     connectionString="metadata=res://*/Model.MyEntities.csdl|res://*/Model.MyEntities.ssdl|res://*/Model.TravldbEntities.msl;
     provider=System.Data.SqlClient;
     provider connection string=&quot;Data Source=sandiego;
                                Initial Catalog=mydatabse;Persist Security Info=True;
                                User ID=user;Password='password';MultipleActiveResultSets=True&quot;"
     providerName="System.Data.EntityClient" />

2 Answers 2

1

What have you tried? I'm not familiar with EF, but why not just try something similar to how a normal C# app would connect:

<add name="MyEntities"
 connectionString="provider=System.Data.SqlClient;
    Data Source=sandiego; -- maybe needs to be sandiego\SQLEXPRESS?
    User ID=user;
    Password=password;">

I would only specify the MARS attribute if you know for sure you need it.

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

Comments

0

Instead of this:

 Data Source=sandiego

Use this:

 Data Source=SomeMachineNameOrIP\SQLExpress

Here's another similar answer.

2 Comments

If it is local mdf file ? Do i have to give full path ?
If you have a database already attached to a SQL Express instance, no it is not a path to an MDF file, it's a reference to an instance of SQL Server Express.

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.