question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Model Size Limited

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
czb182commented, Sep 14, 2018

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.

0reactions
lock[bot]commented, May 5, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why the sizes of the context of models are so limited?
27 votes, 25 comments. I'm trying to grasp some of the concepts of AI models and one thing bothers me - the size...
Read more >
Handling big models for inference
When you have more GPU memory available than the model size, here is the difference between each option: "auto" and "balanced" evenly split...
Read more >
data model limit?
Hi. my data model size is 1.8 GB, I saw the size in dax studio and I'm using power bi service with PRO...
Read more >
Different Size of Machine Learning Models?
Amazon ML sets the limit of Model Size to be between 1 MB to 1GB. The question is mainly revolved about collecting the...
Read more >
What's the real size of your data model in Power BI? - YouTube
From Power BI Desktop, to Task Manager, to different spots in the Power BI service - why are the sizes different? What's going...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found