[英]Entity Framework Null in Class Library
I have a potentially simple issue. 我有一个潜在的简单问题。 My EF code obtains data in every project except one class library. 我的EF代码获取除一个类库之外的每个项目中的数据。 Do I need an additional connection string in my App.config file for this class library? 我的App.config文件中是否需要用于该类库的其他连接字符串? I have all data pulling from a class library called "models" with one connection string for the whole project. 我有一个名为“ models”的类库,其中有一个用于整个项目的连接字符串。 What do you suggest I do? 你建议我做什么? Perhaps this is an issue with my local database too. 也许这也是我本地数据库的问题。 Please let me know if you need more information. 如果您需要更多信息,请告诉我。
Sample: 样品:
public static bool IsAdmin()
{
try
{
using (EmployeeContext _context = new EmployeeContext())
{
string user = WindowsIdentity.GetCurrent().Name;
var adminCheck = (from u in _context.Administration where u.Login.Equals(user) select u).FirstOrDefault();
if (adminCheck == null)
{
return false;
}
else
{
return true;
}
}
}
catch(Exception ex)
{
ErrorLogging.Record(ex.ToString(), ex.StackTrace);
}
return false;
}
在主应用程序中定义连接字符串,问题可能是(尽管我不确定)EF默认为localDB。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.