如何在新的CTP中设置以下内容?

modelBuilder.Entity<RequestBase>()
                .MapHierarchy()
                .Case<RequestBase>(b => new { b.Id, b.Comment, Discriminator = 0 })
                .Case<Request1>(s => new { request1_Id = Column.Id,  Discriminator = 1 })
                .Case<Request2>(m => new { request2_Id = Mission.Id, m.Comment, m.Date, Discriminator = 2 })
                .ToTable("dbo.Requests");

最佳答案

这样的事情会起作用:

modelBuilder.Entity<RequestBase>()
            .Map<RequestBase>(r => r.Requires("Discriminator").HasValue(0))
            .Map<Request1>(r1 => r1.Requires("Discriminator").HasValue(1))
            .Map<Request2>(r2 => r2.Requires("Discriminator").HasValue(2))
            .ToTable("dbo.Requests");

关于c# - EF代码优先CTP 5中MapHierarchy()的替代方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4390825/

10-10 15:24