I\'m confused by the connection string in the Web.config file of project with Entity Framework Web API. There are a lot of variants I tried, but none of them was helping me out.
This tutorial how to setup SQL Server 2008 for an ASP.net website on IIS 7.0 brought me close to the solution.
Basically, what you need to do is
Changing the name of my connection string helped me establish the connection finally.
<connectionStrings>
<add name="MyProjectContext" connectionString="Server=.\SQLEXPRESS;Database=MyProject;User Id=John;Password=duck;" providerName="System.Data.SqlClient" />
</connectionStrings>
The context model required this name.
public class MyProjectContext : DbContext
{
public MyProjectContext() : base("name=MyProjectContext")
{
}
public DbSet<Model1> Model1 { get; set; }
public DbSet<Model2> Model2 { get; set; }
}
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=MyProject;User ID=John;Password=duck" providerName="System.Data.SqlClient" />
</connectionStrings>
Please try the above connection syntax.
Use the Event Viewer to get more information on what the 500 error actually is.
Basically just amend your connection string using Integrated Security=False like :
and it will work ...