2015-03-25 112 views
-2

我一直在得到一個EntityException,其內部異常爲{「無法打開數據庫」Namespace.Model.DbContext 「登錄請求登錄失敗用戶'Domain \ myusername'登錄失敗。」}

{ 「無法打開數據庫\」 Namespace.Model.DbContext \ 「由 登錄請求。登錄失敗登錄失敗,用戶 '域\名爲myUsername'。」}

我明明已經重命名了doman和用戶名,命名空間模型和繼承的dbcontext類名。

可疑故障1,連接字符串:

<add name="Connection2" 
     connectionString=" 
     Data Source=(LocalDB)\v11.0; 
     Database=EmployeeDB; 
     Integrated Security=True" /> 

疑似故障2,代碼:

List<Employee> employees = employeeContext.Employees.ToList(); 
+0

你的域用戶沒有得到對數據庫的訪問。你有沒有檢查訪問權限? – JamesT 2015-03-25 08:46:09

回答

1

我想到這竟然是事實,我是用實體框架,但並沒有提供providerName="System.Data.SqlClient"

2

確保添加數據庫中的用戶的用戶,將他作爲的db_owner:

Example of security section

Example of adding new user

更多信息請查看本Link

相關問題