0

コード2017、EF v 6.0.1を使用してWebアプリケーションを開発しています。アプリケーションを実行しています。従業員のリポジトリクラスでエラーが発生しました。「指定されたファイルが見つかりません」return employeeDBContext.Departments 。Include( "Employees")。ToList(); "。説明を明確にするために画像をアップロードできません。また、オブジェクトデータソースでgridviewを使用しています。 は、以下の接続strings.Soと一緒に私のコードで、間違いがあるweb.configたconnectionStringである指定されたファイルが見つかりません "return employeeDBContext.Departments.Include(" Employees ")。ToList();"

public class Employee 
{ 

    public int Id { get; set; } 
    public string FirstName { get; set; } 
    public string LastName { get; set; } 
    public string Gender { get; set; } 
    public int Salary { get; set; } 

    public Department Department { get; set; } 
} 
public class Department 
{ 
    public int Id { get; set; } 
    public string Name { get; set; } 
    public string Location { get; set; } 

    public List<Employee> Employees { get; set; } 
} 
public class EmployeeDBContext:DbContext 
{ 
    public DbSet<Department> Departments { get; set; } 
    public DbSet<Employee> Employees { get; set; } 
} 
    public class EmployeeRepository 
{ 
    public List<Department> GetDepartments() 
    { 
     EmployeeDBContext employeeDBContext = new EmployeeDBContext(); 
     return employeeDBContext.Departments.Include("Employees").ToList(); 
    } 
} 
<connectionStrings> 
<add name="EmployeeDBContext" providerName="System.Data.SqlClient" 
connectionString="server=.;uid=sa;[email protected];database=Sample;" /> 

The system cannot find the file specified "return employeeDBContext.Departments.ToList(); "

答えて

0

...問題がどこにあるか私に教えてください。私は、サーバー名を変更したコード

<connectionStrings> 
<add name="EmployeeDBContext" providerName="System.Data.SqlClient" connectionString="server=.\SQLSERVERR2;uid=sa;[email protected];database=Sample;" /> 

で次のコード

<connectionStrings> 

を置き換えます。

ありがとうございました........

関連する問題