0

It's very odd behavior of EF and I don't know how to resolve it.

Here's my Entities in MSSQL Management Studio:

Entities screenshot

Then, after generating ADO.NET Entity Data Model:

Generated ADO.NET Entity Data Model

Some Entities are missing(HistoryFabric, HistoryFurniture, ProductFabric). Any ideas how to solve this?

Update:

Datatypes of one of the missing Entity(all missing Entities have the same structure):

enter image description here

John C
  • 1,761
  • 2
  • 20
  • 30
TaPO4eg3D
  • 73
  • 7

1 Answers1

1

That is a one to many mapping table, it will not be a class. It will only show up as a referenced property to the other tables. You will have to explore it and find out what the EF named your foreign key table's property, like with intelesense.

It would be off your foreign key tables. So something like this.

var hJenny = ctxDB.History.Where(h => h.ID == 8675309).FirstOrDefault();
var val = hJenny.ProductArticle.SomeColumn;

Or if you want to use in a query.

var hJenny = ctxDB.History.Where(h => h.ID == 8675309 && h.ProductArticle.Author == 'Jenny').FirstOrDefault();
John C
  • 1,761
  • 2
  • 20
  • 30
  • Seems like it's the correct answer, but how I can access it(to make a query, for example)? I still don't get it. – TaPO4eg3D May 15 '18 at 06:32
  • Updated the answer with an example. – John C May 15 '18 at 06:40
  • Bottom line to remember... If EF sees a table that has nothing but foreign keys in it, it will only use it as a reference property between the two tables it's foreign keys reside. It knows or thinks it is a one to many mapping table. – John C May 15 '18 at 06:50
  • 1
    If someone finds this answer, there is an extended version - https://stackoverflow.com/a/4255078/6844662 – TaPO4eg3D May 15 '18 at 07:25