' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.ComponentModel.DataAnnotations
Imports System.ComponentModel.DataAnnotations.Schema
Imports System.Data.Entity

Namespace MT
    ' parent class
    <Table("P")> Public Class P
        <Key> <DatabaseGenerated(DatabaseGeneratedOption.None)> Public Property Id() As Integer
        Public Property Typ() As Integer
    End Class
    ' child class 1
    <Table("C1")> Public Class C1
        Inherits P
        Public Property Ival() As Integer
        Public Overrides Function ToString() As String
            Return $"C1: {id} -> {ival}"
        End Function
    End Class
    ' child class 2
    <Table("C2")> Public Class C2
        Inherits P
        Public Property Sval() As String
        Public Overrides Function ToString() As String
            Return $"C2: {id} -> {sval}"
        End Function
    End Class
    ' database context
    Public Class TestDbContext
        Inherits DbContext
        Public Sub New(constrkey As String)
            MyBase.New(constrkey)
        End Sub
        Public Property P() As DbSet(Of P)
        Public Property C1() As DbSet(Of C1)
        Public Property C2() As DbSet(Of C2)
    End Class
End Namespace
