Home

Not all navigation properties are shown

I have two identical SQL Server 2014 databases which I have added as connections to Linqpad 5. (I have ensured that the schemas are identical (with schema compare from VS 2017)). For a specific table in the first DB all navigation properties are shown. In the second DB for the same table some of the navigation properties are missing.
Has anybody got an explanation for that?

Comments

  • what I forgot to mention is that for the second DB the database was removed an re-created.
  • I can't think of a reason that would happen. If you can provide a schema that can reproduce the problem of navigation properties not showing, I can look into it. However, it's not always possible for the built-in heuristics to infer a name for association properties, which is why they might not show.
  • Joe, Are the heuristics for association properties described any where?
  • No, there isn't any such document. I've had another look at the code and the most likely reason for omitting an association is that its name would conflict with another association or property name. In these cases, LINQPad should probably add a unique suffix (Customer1, Customer2, etc) rather than omitting it. I can put this on the TODO list.
  • @JoeAlbahari Just as another data point, I've hit that scenario as well where the generated names for properties conflicted so I ended up with only 1 of them and the other just wasn't present. Historically I've been lucky enough to change the FK name such that they then both showed up, but it'd be great to have the suffix approach. :)
  • OK, I'll add this to the next build.
  • James - try now and let me know if it makes any difference.
  • edited January 18

    Hi, I'm having this issue too. Tried it with the latest beta v5.41. I think the problem is that I have a navigation property and a string property that result to the same name:

    class Address 
    {
        Lookup_City Lookup_City;
        string City;
    }
    

    This is the FK:
    ALTER TABLE [dbo].[Campsite.Addresses] WITH CHECK ADD CONSTRAINT [FK_Campsite.Addresses_Lookup.Cities] FOREIGN KEY([CityId])
    REFERENCES [dbo].[Lookup.Cities] ([Id])
    ALTER TABLE [dbo].[Campsite.Addresses] CHECK CONSTRAINT [FK_Campsite.Addresses_Lookup.Cities]

Sign In or Register to comment.