LINQ to Entities:数据库连接失败

时间:2011-07-14 14:08:38

标签: linq entity-framework database-connection

我刚刚将我的数据访问权限从Linq转换为SQL,Linq转换为实体。我已经创建了我的edms并且已经更新了我的类如下,但是我收到任何未找到连接的错误。 错误发生在ModelDesigner.cs文件中。对此有何帮助?谢谢~Susan~

错误报告:

  

在。中找不到指定的命名连接   配置,不打算与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;
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您的连接字符串可能没有指定元数据资源。你可以发布连接字符串吗?

http://msdn.microsoft.com/en-us/library/cc716756.aspx

相关问题