views:

495

answers:

2

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

  1. ToyData (Visual Basic Class Library)

  2. ToyOne (Visual Basic WPF Application)

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

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

It throws this run-time exception in the auto-generated Toy.Designer.vb file:

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?

+2  A: 

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


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.

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.

David B
I added a new Application Configuration File to the ToyOne project and pasted into it the <connectionStrings> section from ToyData's app.config file. It worked.
Zack Peterson
A: 

I only get this problem in the designer for the XAML. When i compile and run the WPF application there is no problem. Any suggestions?

Alex