1
我刚刚将数据访问从Linq转换为SQL到Linq to Entities。我已经创建了我的edms,并且已经更新了我的类,如下所示,但是我收到了连接未找到的任何错误。 错误位于ModelDesigner.cs文件中。对此有何帮助?谢谢〜苏珊〜LINQ to Entities:数据库连接失败
错误报告:
指定命名的连接或者未在 配置中找到,不打算与EntityClient提供者, 或无效使用。
Line 48: /// Initializes a new FVTCEntities object using the connection string found in the 'FVTCEntities' section of the application configuration file.
Line 49: /// </summary>
Line 50: public FVTCEntities() : base("name=FVTCEntities", "FVTCEntities")
Line 51: {
Line 52: this.ContextOptions.LazyLoadingEnabled = true;
这里是我的代码为我的数据访问层:
namespace DL
{
public class DLgetRestaurants
{
FVTCEntities db = new FVTCEntities();
public List<RESTAURANT> getRestaurants(string cuisineName)
{
var cuisineID = db.CUISINEs.First(s => s.CUISINE_NAME == cuisineName).CUISINE_ID;
List<RESTAURANT> result = (from RESTAURANT in db.RESTAURANTs.Include("CITY").Include("CUISINE")
where RESTAURANT.CUISINE_ID == cuisineID
select RESTAURANT).ToList();
return result;
}
}
}
这里是从App_Code文件文件的连接:节点 <添加名称= “FVTCEntities” 的connectionString =“元数据= RES://*/Model.csdl | RES:// * /型号.ssdl | res://*/Model.msl; provider = System.Data.SqlClient; provider connection string = " data source = SFP; attachdbfilename = H:\ ASP.Net \ FVRG \ FVRG \ App_Data \ FVTC.mdf;集成安全= TRUE; multipleactiveresultsets = TRUE;应用=的EntityFramework " “的providerName =” System.Data.EntityClient” /> connectionStrings>节点 –
Susan
如果你把一个断点,并使用ConfigurationManager.ConnectionStrings你确实看到在连接字符串中有? – Jeff
对不起,我之前没有使用Confg Mgr。我打开了BUILD。配置经理。我如何选择ConnectionStrings?另外,应该在我的设计器文件中设置断点吗? – Susan