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=&qu开发者_如何学Goot;Data Source=sandiego;
Initial Catalog=mydatabse;Persist Security Info=True;
User ID=user;Password='password';MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
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.
Instead of this:
Data Source=sandiego
Use this:
Data Source=SomeMachineNameOrIP\SQLExpress
Here's another similar answer.
精彩评论