LinqPad 5 with EFCore - TypeLoadException: Inheritance security rules violated by type: 'Remotion.Li


Posted a query on Stack Overflow here but didn't appear to get any traction.

Anyone have a solution to (or had a similar issues, so I can identify if its my setup or a broader issue) the following error when trying to query an EFCore DbContext from LinqPad against SQL Express..

TypeLoadException: Inheritance security rules violated by type: 'Remotion.Linq.Parsing.RelinqExpressionVisitor'. Derived types must either match the security accessibility of the base type or be less accessible.

I found a similar issue posted here but with no resolution either..

Anyone any ideas?



  • Do you have the AllowPartiallyTrustedCallers attribute set on your DbContext assembly, or any other code-access security attributes?

    If so, try removing them.
  • Hi Joe,

    Thanks for coming back to me. Nothing special with the DB context apart from inherting from IdentityDbContext.

    Just to be sure, I cloned and ran the sample code as part of the EFCore official tutorial here:

    I have modified the sample slightly, firstly to move the data stuff to a netstandard2.0 lib as the 'EF Core Driver v2.2' doesn't appear to support netcoreapp.

    I also added the 'CopyLocalLockFileAssemblies' attribute to the Data.csproj to copy all assemblies to the output folder, so I can reference the Data.dll from /data/bin/debug/netstandard2.0

    Finally I added support to the DbContext for using a parameterless constructor

    You can find the minimal sample here:

    When I create the connection with the following settings:

    It finds and loads the tables:

    However trying to execute any sort of query blows up:

    Any thoughts?


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!