In developing a test harness to validate name changes I made to entities, entity sets, and association sets for a EDM based on the Northwind database (Access version), I wrote some code to retrieve and display foreign key values and related entity counts for entity sets loaded in a DataGridView.
I'm seeing a problem of consistency in foreign key values returned from the 1:1 Employees.ReportsTo:Employees.EmployeeID association. The initial values when loading the related entities are correct for the nine Employee instances. However, data returned from the cache is missing six of the nine values.
Screen captures of the initial and final diagram, as well as test harness results, plus code snippets are in today's post on the OakLeaf blog. The last two screen captures illustrate the differences between the initial and cached contents of the DataGridView control.
I haven't done exhaustive testing of other tables for this problem, but the don't appear to exhibit this problem.
Questions:
1. Is this a known problem If so, is there a workaround
2. Is there a more efficient method of obtaining single property values (primary keys) from related entities than loading the entire instance into memory
3. Is there a simple method to clear the cache
Thanks in advance,
--rj

Problem with 1:1 Association in EDM Designer
reichard
Hi! Roger,
Thanks for downloading and trying out the EDM Designer prototype. I'll try & answer your questions; do keep those questions coming...
RE #1: I'm seeing a problem of consistency in foreign key values returned from the 1:1 Employees.ReportsTo:Employees.EmployeeID association. The initial values when loading the related entities are correct for the nine Employee instances. However, data returned from the cache is missing six of the nine values.
Its hard to tell what's going on without looking at your CSDL, SSDL and MSL files. Please can you include them so we can repro & identify the problem
RE: #2: Is there a more efficient method of obtaining single property values (primary keys) from related entities than loading the entire instance into memory
If you mean whether there is a way of obtaining a single property out of an entity without fetching the whole entity, you can simply project a value in the projection list using either esql or linq (e.g. in esql “select p.name from people as p”). You can also use query<t> to do this. You can get the keys this way too, provided that the keys are mapped to entity properties (which true for ADO.NET vNext).
RE: #3: Is there a simple method to clear the cache
No, we do not have a method to clear the cache. As an alternate, you could throw away the context and construct a new instance which will have a new cache.
Regards,
Sanjay
Tommysaurusrex
Hi, Sanjay,
I sent the zip of the VB EDM test harness to you a few minutes ago. There's a minor change to the form that isn't in the blog screen captures: counts of instances retrieved to obtain foreign key values. The Employees count occasionally shows 839 or 848 instead of 830. Occurence of the extra 9 or 18 instances is random.
Thanks for your help,
--rj
MartinMalek
hula_samvaad
Sanjay,
Thanks for the reply.
Re #1: If you'll send your email alias to me at roger_jennings-at-compuserve.com, I'll zip up and send you the VB test harness that's described in my recently updated blog post about ADOEF and the Designer. The harness runs against Northwind on SQL Server 2005, so will need a fixup to the connection string. I'm seeing strange issues with performance (80 - 120 seconds to execute ~2,500 queries to retrieve 830 Orders instances plus CustomerID, EmployeeID, and ShipperID values) and the uniquing of Employee instances for a ReportsTo hierarchy.
Re #2: What I meant was obtaining foreign key values from a parent table, such as CustomerID from the Northwind Orders table, without the heavy lifting of retrieving an Orders instance. I thought that oSQL's NAVIGATE operator might work, but couldn't come up with the syntax. (There are _very_ few useful (non-trivial) eSQL syntax examples.) Similarly, I wasn't able to figure out the Navigation property syntax within the For Each ... Next loop of instances returned by LINQ for Entities.
Re #3: Daniel Simmions reply cleared up this question.
Thanks in advance for your help on questions 1 and 2.
--rj