Are generic classes not supported as models in Entity Framework?

后端 未结 2 909
遥遥无期
遥遥无期 2020-12-19 02:04

I am trying to do something like this :

public class TrackerContext : DbContext
{
    public bool TrackNewValues { get; set; }

    public TrackerContext(boo         


        
2条回答
  •  攒了一身酷
    2020-12-19 02:51

    I have been using generic classes with success in Entity Framework. If you declare your class and DbSet the following way it will work.

    public class AuditLogString : AuditLog{}
    
    public DbSet  AuditLogStrings { get;set;}
    

    [Update] I have not used this method recently and in the light of the comments on this answer I suggest Pawel's answer instead. However I have not deleted this answer since I was able to use the method.

提交回复
热议问题