0

I generated a Visual Studio 2010 entity data model derived from a (mysql) database.

Users
- UserID
- Username
- UserGroupID

Groups
- GroupID
- GroupName

The edmx diagram properly shows the relationship between the two tables (one to many). If I drag & drop the users datasource onto a form, a datagridview shows up, and it is correctly populated with the username, etc when I run the application. However, it shows column with the (correct) UserGroupID, instead of GroupName. I tried to follow these instructions to get the GroupName to show up, but then I get an error that says

Error 3024: Problem in mapping fragments starting at line ###:Must specify mapping for all key properties ...

It seems that this works for one-to-one relationships but not one-to-many.

Is it not possible to display the users table with the groupname in a datagridview without adding classes manually, when using a model-first entity data model? If it is indeed not possible, then what is the simplest way to display (and edit) this in datagridview (i.e., possibly not using entity data model?) I thought this would be a rather common scenario, which makes make think that there should be a visual tool-based approach for doing this.

As a tolerable approach, I tried to create a view that displays what I like. I was able to add that view to the model, and add the entity as a data source. However, when dragging that data source onto a form, nothing was displayed in the datagridview. The plot thickens.

Community
  • 1
  • 1
Jimmy
  • 5,131
  • 9
  • 55
  • 81

1 Answers1

0

Pff! I gave up on the entity model, and just ended up using good old MySqlAdapter, BindingSource, DataTable.

Jimmy
  • 5,131
  • 9
  • 55
  • 81