0

I have a Table with these columns

Id as integer
Name as string
Image as byte()

then I made two POCO

Public Class TableBase
     Id as Integer
     Name as String
End Class

Public Class Table
    Inherts TableBase
    Image as byte()
End Class.

Because I not always I need to load the image. The problem is that I received a discrimination error, and the solutions of TPH stuff don’t resolve it. Because I can’t add a discrimination column to database table.

   ...
    modelBuilder.Entity<Table>()
    .Map(mc => mc.Requires("TableType").HasValue("Base"))
   ...

Actually I don’t have a hierarchy problem; I just need to load POCO partially

Regards!

neo
  • 83
  • 7

1 Answers1

0

You don't need TPH because in TPH record in the database can be represented by only one entity type - that means it will be either TableBase or Table but never both.

You need table splitting.

Community
  • 1
  • 1
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • Actually after a lot of reading I think your are right, the best solution is table splitting. thats mean an inconvenience for me because my Razor Views are created with Reflection in runtime. By the way, I will leave to inherit in my POCO :( – neo Aug 09 '11 at 17:43