Hoping someone can help me track down a very unrevealing problem. I have a project that uses Web API 2 and Entity Framework 6 on .NET Framework 4.7.2. The project has been working fine for years, we recently decided to incorporate a couple additional databases in our project. As it turned out EF6 doesn't support similarly named Classes in different Models. Their are some hacky workarounds, Custom Tool Name Spacing and other such things. Alternatively, MS and some other SO posts recommended moving to .NET Core and Core EF. An attempt was made to migrate but it turns out that it's more of a port/re-write because many EF6 features are deprecated EF Core. As it is we bailed and decided to completely re-approach. We rolled the code back and chased down a couple nuanced issues and everything appeared to be working, except for one Class/API call which was discovered before we published code.
[CustomAuthorize(Roles = "admin, sales, parts")]
[Route("api/Customer/Get")]
[HttpPost]
public MERP.Customer GetCustomerProfile([FromBody] Models.Generic.GuidValue _input)
{
MARQERPEntities ent = new MARQERPEntities();
var cst = ent.Customers.FirstOrDefault(w => w.ID == _input.ID);
return cst;
}
Stepping thru the code, the cst variable gets populated with the database object and the return step is executed. However, the payload never arrives at the client. If I open Task Manager the IIS Express Worker Process keeps churning away until all the memory is consumed and the following error is returned. I have other API endpoints using the same code pattern and they work fine.
An unhandled exception of type 'System.AccessViolationException' occurred in Unknown Module. Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I'm not sure how to proceed here. I've blown away the EDMX and started over, I've removed and re-added the Customer class. The other Database Entities have been removed. I've compared our current packages.config to the pre EF Core Change Set and they're the same.
Here's the packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net472" />
<package id="jQuery" version="3.1.1" targetFramework="net472" />
<package id="Microsoft.AspNet.Cors" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Cors" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.HelpPage" version="5.2.4" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net472" />
<package id="Microsoft.AspNetCore.WebUtilities" version="2.0.2" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging" version="2.0.2" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="2.0.2" targetFramework="net472" />
<package id="Microsoft.Extensions.Options" version="2.0.2" targetFramework="net472" />
<package id="Microsoft.Extensions.Primitives" version="2.0.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Logging" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Protocols" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Protocols.WsFederation" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Tokens" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Tokens.Saml" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Xml" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.Net.Http.Headers" version="2.0.2" targetFramework="net472" />
<package id="Microsoft.Owin" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Security" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Security.ActiveDirectory" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Security.Jwt" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Security.OAuth" version="4.0.1" targetFramework="net472" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net472" />
<package id="Owin" version="1.0" targetFramework="net472" />
<package id="PuppeteerSharp" version="1.12.0" targetFramework="net472" />
<package id="PuppeteerSharp.AspNetFramework" version="1.12.0" targetFramework="net472" />
<package id="System.Buffers" version="4.4.0" targetFramework="net472" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.5.0" targetFramework="net472" />
<package id="System.IO" version="4.3.0" targetFramework="net472" />
<package id="System.Net.Http" version="4.3.3" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net472" />
<package id="System.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="4.4.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.1" targetFramework="net472" />
</packages>