I’m trying to follow the Contoso University tutorial, only with SQL Server 2008 instead of CE. I can connect to the database engine in SQL Server Management Studio using my PC’s name and windows authentication. I haven’t created a database with it because I’m trying to use EF Code First.
This is my connection string:
<add
name="SchoolContext"
connectionString="Data Source=CARSON-PC\CARSON;Integrated Security=true"
providerName="System.Data.SqlClient"/>
I try to add a controller by right-clicking the controllers folder and selecting Add->Controller... and setting up the resulting dialog according to the tutorial. I wind up with a dialog telling me a FileNotFoundException was thrown, and the file is a temporary dll:

This dialog is thrown up five times (once for each of the generated template files, I assume) and I wind up with a controller but no generated templates.
I suspect it’s to do with either my connection string or my SQL server installation, since I’ve been stuck on this a while, getting various errors at this stage as I try and get the connection string right.
For completeness, here’s the model I’m trying to generate a controller for:
public class Student {
public int StudentID { get; set; }
public string LastName { get; set; }
public string FirstMidName { get; set; }
public DateTime EnrollmentDate { get; set; }
public virtual ICollection<Enrollment> Enrollments { get; set; }
}
And the context:
public class SchoolContext : DbContext {
public DbSet<Student> Students { get; set; }
public DbSet<Enrollment> Enrollments { get; set; }
public DbSet<Course> Courses { get; set; }
protected override void OnModelCreating(modelBuilder As DbModelBuilder) {
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
Is my connection string wrong? Is this a symptom of something not configured right with the server? What am I screwing up here?
This turned out to be a simple bug in the MVC template files List.tt, Edit.tt, Details.tt, etc. There was an ambiguous reference to
ColumnAttribute.I opened
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates\AddView\CSHTML, and going through each of the.ttfiles and searching for ” ColumnAttribute” (with the space at the beginning):I changed that first line to:
I think only Empty.tt didn’t have it. I did the same for the VB templates. Now the controllers are created fine.