我下面的教程如下图所示链接:无法加载文件或程序集或其依赖项。该系统找不到指定的文件
Creating an Entity Framework data model for ASP.NET MVC application
但在运行应用程序,以下异常谈到:
系统。 IO.FileNotFoundException:无法加载文件或程序集“Vag_Infotech”或其某个依赖项。该系统找不到指定的文件。
我的web.config文件如下:
<connectionStrings>
<add name="CollegeDbContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=VInfotech;Integrated Security=SSPI" providerName="System.Data.SqlClient"/>
</connectionStrings>
<contexts>
<context type="Vag_Infotech.DAL.CollegeDbContext, Vag_Infotech">
<databaseInitializer type="Vag_Infotech.DAL.CollegeDatabaseInitializer, Vag_Infotech"></databaseInitializer>
</context>
</contexts>
CollegeDbContext类:
namespace Vag_Infotech.DAL
{
public class CollegeDbContext : DbContext
{
public CollegeDbContext()
: base("CollegeDbContext")
{
}
public DbSet<Student> Students { get; set; }
public DbSet<Course> Courses { get; set; }
public DbSet<Enrollment> Enrollments { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
}
唯一的例外来自于StudentController.cs类:
我还没有做到这一点,因为在本教程中,它被指定为制作一个dll。 @Tobberoth –
您的命名空间名为Vag_Infotech?它似乎有问题找到它。你可以发布你的CollegeDbContext类的代码吗?或者可能是来自DAL文件夹的初始化程序代码,因为这似乎是关键问题。 – Tobberoth
@Tobberoth是的。我在创建应用程序时犯了一个错误,我输入了应用程序Vag Infotech的名称。 –