实体框架上下文不起作用
我正在尝试找出实体框架,但我不断遇到上下文问题。我创建了 .edmx 文件,它工作正常,但是当我尝试在页面上声明我的上下文时,Visual Studio 将找不到它们。我的 .edmx 文件名为 YCLModel.edmx,它的连接字符串是 YCLEntites。
我尝试将上下文声明为:
Dim yclcontext as new YCLEntites
我还尝试进入设计模式并从工具箱中拖动,但是当我选择命名连接时,它会出现以下错误:
无法加载连接字符串中指定的元数据。 考虑重建 Web 项目以构建可能的程序集 包含元数据。发生以下错误:
无法加载指定的元数据资源。
I am trying to figure out Entity Framework but I keep running into issues with the context. I create my .edmx file and it works fine but when I try to declare my context on my pages Visual Studio will not find them. My .edmx file is called YCLModel.edmx and my connectionstring for it is YCLEntites.
I try to declare the context as:
Dim yclcontext as new YCLEntites
I have also tried going into design mode and dragging from the toolbox but when I select my named connection it gives me the following error:
The metadata specified in the connection string could not be loaded.
Consider rebuilding the web project to build assemblies that may
contain metadata. The following error(s) occurred:Unable to load the specified metadata resource.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否在 Web 项目之外的单独项目中定义了 .edmx 文件?如果是这样,您应该将连接字符串数据从项目的
app.config
复制到您的 Web 项目。Do you have your .edmx file defined in a separate project other than your web project? If so, you should copy the connection string data from the
app.config
of your project to your web project.问题是
edmx
文件位于app_data
文件夹中。The issue was the
edmx
file was in theapp_data
folder.