我下面的教程如下圖所示鏈接:無法加載文件或程序集或其依賴項。該系統找不到指定的文件
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的名稱。 –