如何使用LINQ在Visual Basic实体? [英] How do I use LINQ to Entities in Visual Basic?

查看:138
本文介绍了如何使用LINQ在Visual Basic实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个.NET解决方案有两个项目:

I've created a .NET solution with two projects:

  1. ToyData(Visual Basic中类库)

  1. ToyData (Visual Basic Class Library)

丰根(Visual Basic中的WPF应用程序)

ToyOne (Visual Basic WPF Application)

该ToyData项目包含的 Toy.edmx 的,从一个叫玩具数据库生成一个ADO.NET实体数据模型。

The ToyData project contains Toy.edmx, an ADO.NET Entity Data Model generated from a database called Toy.

本丰根项目包含此的 Window1.xaml.vb 的文件:

The ToyOne project contains this Window1.xaml.vb file:


1   Imports ToyData
2   
3   Class Window1
4   
5       Private Sub Window1_Loaded( _
6       ByVal sender As System.Object, _
7       ByVal e As System.Windows.RoutedEventArgs) _
8       Handles MyBase.Loaded
9   
10          Dim dc As New ToyEntities
11          Label1.Content = (From c As Client In dc.ClientSet _
12                            Select c).First
13  
14      End Sub
15  
16  End Class

它抛出此运行时异常的自动生成的 Toy.Designer.vb 的文件:


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

我是什么做错了吗?

What am I doing wrong?

推荐答案

我见过这个问题的服务项目和一个测试项目(使用在服务中定义的数据对象)。

I've seen this issue before between a service project and a test project (that uses the data objects defined in the service).


如果你右键点击新的 ToyEntities 的,去定义,并保持钻探...你会得到一些自动生成的code表示获取连接字符串从一个配置文件。

If you right click on "new ToyEntities" and go to definition, and keep drilling in... you'll get to some auto-generated code that fetches a connection string from a config file.

检查ToyData项目的配置文件。值复制到一个app.config文件(可能还不存在),对其他项目。

Check the ToyData project for a config file. Copy the values into an App.Config file (it may not exist yet) for the other project.

这篇关于如何使用LINQ在Visual Basic实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆