嗨,即使在阅读了提示后,我仍然在使用 MVC 制作控制器时遇到问题。在 DbContext 上添加构造函数,删除未工作的,更改 providerName="System.Data.SqlClient" 等等。
我的模型类如下所示:
public class RecruiterModel
{
public string CompanyName { get; set; }
public string Website { get; set; }
public string CompanySize { get; set; }
public string LinkedInCompanyURL { get; set; }
public string LinkedInID { get; set; }
public string Specialities { get; set; }
public string Category { get; set; }
public string Location { get; set; }
public int ContactPhone { get; set; }
public string ContactEmail { get; set; }
}
public class RecruiterDBContext : DbContext
{
public DbSet<RecruiterModel> Recruiters { get; set; }
}
我的 web.config connectionStrings 看起来像这样:
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="RecruiterDBContext"
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Recruiters.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"
/>
有小费吗?