I've created a new MVC 3 website using EF 4.1 with DB first approach. I've created the edmx file and then the DBContext (the new 4.1 feature) classes. all went well.
Then, I've created new controllers using the automatic creation for DBContext. All wen't great.
Now, that I'm trying to fire up the website it won't connect to the connection string itself created.
Here is the connection string:
<add name="PizzaByMeEntities"
connectionString='metadata=res://*/Models.PizzaByMeModel.csdl|
res://*/Models.PizzaByMeModel.ssdl|
res://*/Models.PizzaByMeModel.msl;
provider=System.Data.SqlClient;
provider connection string="data source=(local);
initial catalog=PizzaByMe;
integrated security=True;
pooling=False;
multipleactiveresultsets=True;
App=EntityFramework;"'
providerName="System.Data.EntityClient" />
When I fire up the website I get:
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)
The strange part is that if I remove the connection string - I still get the exact same error. I guess that the EF just can't find the Connection String even when it's there.
Any ideas?
Thanks!
EDIT:
My DBContext is as follows:
public partial class PizzaByMeEntities : DbContext
{
public PizzaByMeEntities()
: base("name=PizzaByMeEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public DbSet<X> Xs{ get; set; }
public DbSet<Y> Ys{ get; set; }
public DbSet<Z> Zs{ get; set; }
}
EDIT 2:
the working connection string is this:
<add name="PizzaByMe" connectionString="Data Source=(local);initial catalog=PizzaByMe;integrated security=True;pooling=False;multipleactiveresultsets=True;" providerName="System.Data.EntityClient" />
Though to make it work - I just used direct ADO.NET connection.