Keyword not supported: 'name'

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-06 23:57:49

问题


So I'm going through this tutorial that seems so simple but I can't seem to get it to work. http://msdn.microsoft.com/en-us/data/gg685489

This is the error I'm receiving when running my app: "Keyword not supported: 'name'."

Now I've looked at other posts similar to mine and it seemed like the connection string was the issue. So I looked closely at but can't see any real differences.

    <add name="BBCommercialSolutionsEntities" 
     connectionString="metadata=res://*/Models.BBCommercialSolutions.csdl|res://*/Models.BBCommercialSolutions.ssdl|res://*/Models.BBCommercialSolutions.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=MYSOURCENAME;initial catalog=MYDATABASENAME;multipleactiveresultsets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />

In my CompanyController.cs class, I receive the error when using the .ToList().

    public ActionResult Index()
    {
        //return View();
        using (var db = new BBCommercialSolutionsEntities())
        {
            //return View(db.BBCSCompanies.ToList());
            var tbl = db.BBCSCompanies;

            var list = tbl.ToList();

            return View(tbl.ToList());
        }
    }

And "new BBCommercialSolutionsEntities()" goes to my auto-generated template

    public BBCommercialSolutionsEntities()
        : base("name=BBCommercialSolutionsEntities")
    {
    }

Any ideas, thoughts, explanations, rants would help.


回答1:


Just use BBCommercialSolutionsEntities

public BBCommercialSolutionsEntities() : base("BBCommercialSolutionsEntities")
{
}


来源:https://stackoverflow.com/questions/9236554/keyword-not-supported-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!