Model Size Limited
See original GitHub issueI posted the below in the EF Core Repository thinking that the error was being produced by EF Core. According to them, the error is coming from Automapper itself. I am using the ProjectTo Queryable Extension.
I have a fairly large Model object with a lot of nested arrays and objects. Works fine in EF6. However attempting to project the same in EF Core throws an error. Its a fairly simple projection and I can tell its something to do with the size of the model that is throwing the error. If I comment out ANY two of the nested objects the error goes away. If I breakup the same model into two or three different objects with the same projection, it works.
Exception message: ArgumentException: Type name was too long. The fully qualified type name must be less than 1,024 characters.
Parameter name: fullname
Stack trace:
System.Reflection.Emit.TypeBuilder.Init(string fullname, TypeAttributes attr, Type parent, Type[] interfaces, ModuleBuilder module, PackingSize iPackingSize, int iTypeSize, TypeBuilder enclosingType)
System.Reflection.Emit.ModuleBuilder.DefineType(string name, TypeAttributes attr, Type parent, Type[] interfaces)
AutoMapper.Execution.ProxyGenerator.EmitProxy(TypeDescription typeDescription) in ProxyGenerator.cs
AutoMapper.LockingConcurrentDictionary<TKey, TValue>+<>c__DisplayClass2_1.<.ctor>b__1() in LockingConcurrentDictionary.cs
System.Lazy<T>.ViaFactory(LazyThreadSafetyMode mode)
System.Lazy<T>.ExecutionAndPublication(LazyHelper executionAndPublication, bool useDefaultConstructor)
System.Lazy<T>.CreateValue()
AutoMapper.Execution.ProxyGenerator.GetSimilarType(Type sourceType, IEnumerable<PropertyDescription> additionalProperties) in ProxyGenerator.cs
AutoMapper.QueryableExtensions.ExpressionBuilder+FirstPassLetPropertyMaps.GetSubQueryExpression(ExpressionBuilder builder, Expression projection, TypeMap typeMap, ExpressionRequest request, Expression instanceParameter, IDictionary<ExpressionRequest, int> typePairCount) in ExpressionBuilder.cs
AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request, IDictionary<ExpressionRequest, int> typePairCount, LetPropertyMaps letPropertyMaps) in ExpressionBuilder.cs
System.Lazy<T>.ViaFactory(LazyThreadSafetyMode mode)
System.Lazy<T>.ExecutionAndPublication(LazyHelper executionAndPublication, bool useDefaultConstructor)
System.Lazy<T>.CreateValue()
AutoMapper.QueryableExtensions.ExpressionBuilder.GetMapExpression(Type sourceType, Type destinationType, object parameters, MemberInfo[] membersToExpand) in ExpressionBuilder.cs
AutoMapper.QueryableExtensions.ProjectionExpression.To<TResult>(object parameters, Expression<Func<TResult, object>>[] membersToExpand) in ProjectionExpression.cs
AutoMapper.QueryableExtensions.Extensions.ProjectTo<TDestination>(IQueryable source, Expression<Func<TDestination, object>>[] membersToExpand) in Extensions.cs
FinBrook.Application.FindDealByIdQueryHandler.Handle(FindDealByIdQuery request, CancellationToken cancellationToken) in FindDealByIdQueryHandler.cs
+
return await _context.Deals
FinBrook.Application.RequestPerformanceBehaviour<TRequest, TResponse>.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate<TResponse> next) in RequestPerformanceBehaviour.cs
+
var response = await next();
MediatR.Pipeline.RequestPreProcessorBehavior<TRequest, TResponse>.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate<TResponse> next)
FinBrook.API.Deals.DealsController.FindDealByIdAsync(int id) in DealsController.cs
+
return Ok(await Mediator.Send(new FindDealByIdQuery()
lambda_method(Closure , object )
Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable+Awaiter.GetResult()
Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor+AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ExceptionContext context)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Steps to reproduce
I cant reproduce the model here as its fairly large. However, if really necessary I’ll try and post it.
Further technical details
EF Core version: 2.1.3 Database Provider: Microsoft.EntityFrameworkCore.SqlServer Operating system: Windows 10 IDE: VS 15.8
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
fyi, I got this same error today on an EF 6.2.0 app after upgrading to automapper 7.0.1 from 6.2.2.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.