Dec 17, 2019 04:22 AM|DA924|LINK
It's still confusing as to how City is being derived and loaded. The example code you are showing the query is against no database controlled by EF. Is City supposed to be in a collection held in memory? If City objects were in a Cities collection, then
you can query Cities with Linq, which is many City objects in the Cities collection. And if States were a collection too, then you can do a Join. But you just can't query City by itself a single object held in memory that is standalone, unless the single object
was in the Cities collection by itself. You can't enumerate over a single object, a standalone single object. You can't loop over a single object in memory. You can loop over objects in an array or collection becuase they are enumerable.
Linq is a language that expects data objects to be in a tubular format that is enumerable, becuase that is what Linq does, and it accesses objects in a collection, array or datatable by enumeration. A tubular format is an array, collection, datatable etc.
and ect, which are objects that can be enumerated over.
I think your big problem here is that you are using EF Code first, and you don't know how to build the Model when you should be using a Model using EF that builds the Model from an existing database. The database is built by you using MS SQL Server Express
and MS SQL Server Management Stuido where SSMS will guide you in making the tables and relationships. Then EF will create the EF Model correctly from an existing database. That's how I do it, becuase SSMS will catch you if you go wrong and will stop you if
doing something erroneously in making tables and relationships.
Error CS1936 Could not find an implementation of the query pattern for source type 'City'. 'Join' not found.
You can't do what you are trying to do in your Linq query, becuase City is not a collection of City objects in a collection object that can be enumerated over. You can't Join on a single object that is standalone with a collection object. There has to be
two or more collections involved in the join, like the collection being joined with another collection or collections.