How to force DbEntityValidationException?

Viewed 16

I need to do some testing, and I need to force the DbEntityValidationException. I'm trying with these lines of code, trying to save with invalid id, trying to add instead of numeric value, a string value, but I keep getting DBUpdateException, and I need the DbEntityValidationException. Can you please help with an idea what I need to insert in order to get this exception? Thanks!

        Dim lRndvrq = New RndvRq
        Dim lRndvrqAc = New RndvRqAc

        lRndvrq.RQ = 663
        lRndvrq.RT_CL = "RQ"
        lRndvrqAc.UP = 1
        lRndvrqAc.RQ = 0 'lRndvrq.RQ
        lRndvrqAc.AR = RnD.Common.Enums.AccessRight.Read

        lRndvrq.RndvRqAc.Add(lRndvrqAc)

        Context.RndvRq.Add(lRndvrq)
        Context.SaveChanges()
0 Answers
Related