开发者

LINQ to Entities: DB connection failed

开发者 https://www.devze.com 2023-03-20 12:59 出处:网络
I\'ve just converted my data access from Linq to SQL to Linq to Entities.I\'ve created my edms and a have updated my class as follows but I\'m getting any error that the connection is not found.The er

I've just converted my data access from Linq to SQL to Linq to Entities. I've created my edms and a have updated my class as follows but I'm getting any error that the connection is not found. The error is in the ModelDesigner.cs file. Any help on this? Thanks ~susan~

Error report:

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

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;

Here is my code for my Data Access Layer:

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;
        }
    }
}


Chances are your connection string doesn't have the metadata resources specified. Can you post your connection string?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消