Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LINQPad error: 'UserQuery': cannot derive from sealed type 'My.Entity.Framework.CustomDataContext'

LINQPad has suddenly started failing to run queries using an Entity Framework assembly. Everything seems to be in order, so I'm a bit confused why it's not working. My app works fine.

The error is:

'UserQuery': cannot derive from sealed type 'My.Entity.Framework.CustomDataContext'

Any ideas on how to get this working again? I can find no mention of this error online.

like image 425
Drew Noakes Avatar asked Oct 06 '22 23:10

Drew Noakes


1 Answers

UserQuery is the type that contains your code in LinqPad. If you use a custom Entity Framework context from your own assembly, UserQuery inherits from this context class. But in your case it seems that your custom EF context class is sealed, so you can't inherit from it.

If for some reason you can't "unseal" it, don't try to use the LinqPad data connection system; just reference the assembly containing your EF context and create an instance of the context explicitly.

like image 163
Thomas Levesque Avatar answered Oct 10 '22 11:10

Thomas Levesque