Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting Entity Framework connection string to SQL Server Express

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" />
like image 884
AnyOne Avatar asked Mar 13 '26 19:03

AnyOne


1 Answers

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.

like image 139
Aaron Bertrand Avatar answered Mar 16 '26 10:03

Aaron Bertrand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!