SaiGonSoftware / Awesome-CMS-Core

Awesome CMS Core is an open source CMS built using ASP.Net Core & ReactJS with module seperation concern in mind and provide lastest trend of technology like .Net Core, React, Webpack, SASS, Background Job, Message Queue.
https://awesomecmscore.azurewebsites.net/
Apache License 2.0
417 stars 136 forks source link

automapper error when deploy to azure #362

Closed ngohungphuc closed 5 years ago

ngohungphuc commented 5 years ago

Full error log

2019-03-24 02:52:13.7016||DEBUG|AwesomeCMSCore.Program|init main |url: |action: 
2019-03-24 02:52:48.3076||WARN|AspNet.Security.OpenIdConnect.Server.OpenIdConnectServerHandler|Disabling the transport security requirement is not recommended in production. Consider setting 'OpenIdConnectServerOptions.AllowInsecureHttp' to 'false' to prevent the OpenID Connect server middleware from serving non-HTTPS requests. |url: https://awesomecmscore.azurewebsites.net/|action: 
2019-03-24 02:52:54.4465|20500|WARN|Microsoft.EntityFrameworkCore.Query|The LINQ expression 'where [p].PostStatus.Equals(Published)' could not be translated and will be evaluated locally. |url: https://awesomecmscore.azurewebsites.net/api/v1/Index|action: GetAll
2019-03-24 02:52:55.4455|20500|WARN|Microsoft.EntityFrameworkCore.Query|The LINQ expression 'where [p].PostStatus.Equals(Published)' could not be translated and will be evaluated locally. |url: https://awesomecmscore.azurewebsites.net/api/v1/Index|action: GetAll
2019-03-24 02:52:55.4679|20500|WARN|Microsoft.EntityFrameworkCore.Query|The LINQ expression 'Take(__p_0)' could not be translated and will be evaluated locally. |url: https://awesomecmscore.azurewebsites.net/api/v1/Index|action: GetAll
2019-03-24 02:52:55.7816|20500|WARN|Microsoft.EntityFrameworkCore.Query|The LINQ expression 'where [p].PostStatus.Equals(Published)' could not be translated and will be evaluated locally. |url: https://awesomecmscore.azurewebsites.net/api/v1/Index|action: GetAll
2019-03-24 02:52:55.7816|20500|WARN|Microsoft.EntityFrameworkCore.Query|The LINQ expression 'FirstOrDefault()' could not be translated and will be evaluated locally. |url: https://awesomecmscore.azurewebsites.net/api/v1/Index|action: GetAll
2019-03-24 02:52:57.1257||ERROR|AwesomeCMSCore.Modules.Client.Repositories.PostRepository|Error mapping types.

Mapping types:
IEnumerable`1 -> IEnumerable`1
System.Collections.Generic.IEnumerable`1[[AwesomeCMSCore.Modules.Entities.Entities.Post, AwesomeCMSCore.Modules.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -> System.Collections.Generic.IEnumerable`1[[AwesomeCMSCore.Modules.Admin.ViewModels.PostListViewModel, AwesomeCMSCore.Modules.Admin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] |url: https://awesomecmscore.azurewebsites.net/api/v1/Index|action: GetAll
2019-03-24 02:52:57.2826|1|ERROR|Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware|An unhandled exception has occurred while executing the request. AutoMapper.AutoMapperMappingException: Error mapping types.

Mapping types:
IEnumerable`1 -> IEnumerable`1
System.Collections.Generic.IEnumerable`1[[AwesomeCMSCore.Modules.Entities.Entities.Post, AwesomeCMSCore.Modules.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -> System.Collections.Generic.IEnumerable`1[[AwesomeCMSCore.Modules.Admin.ViewModels.PostListViewModel, AwesomeCMSCore.Modules.Admin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] ---> AutoMapper.AutoMapperConfigurationException: 
Unmapped members were found. Review the types and members below.
Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type
For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters
===========================================================================================================
AutoMapper created this type map for you, but your types cannot be mapped using the current configuration.
Post -> PostListViewModel (Destination member list)
AwesomeCMSCore.Modules.Entities.Entities.Post -> AwesomeCMSCore.Modules.Admin.ViewModels.PostListViewModel (Destination member list)

Unmapped properties:
Tags
Categories

   at AutoMapper.ConfigurationValidator.AssertConfigurationIsValid(IEnumerable`1 typeMaps)
   at AutoMapper.MapperConfiguration.AssertConfigurationIsValid(TypeMap typeMap)
   at lambda_method(Closure , IEnumerable`1 , IEnumerable`1 , ResolutionContext )
   --- End of inner exception stack trace ---
   at lambda_method(Closure , IEnumerable`1 , IEnumerable`1 , ResolutionContext )
   at AutoMapper.Mapper.AutoMapper.IMapper.Map[TSource,TDestination](TSource source)
   at AwesomeCMSCore.Modules.Client.Repositories.PostRepository.GetIndexViewModel() in D:\SourceCode\Azure-Deployment\ACC\Modules\AwesomeCMSCore.Modules.Client\Repositories\PostRepository.cs:line 50
   at AwesomeCMSCore.Modules.Client.Controllers.API.V1.HomeController.GetAll() in D:\SourceCode\Azure-Deployment\ACC\Modules\AwesomeCMSCore.Modules.Client\Controllers\API\V1\HomeController.cs:line 24
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at AwesomeCMSCore.Extension.ApplicationBuilderExtension.<>c.<<SetupEnv>b__1_0>d.MoveNext() in D:\SourceCode\Azure-Deployment\ACC\AwesomeCMSCore\Extension\ApplicationBuilderExtensions.cs:line 59
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)|url: https://awesomecmscore.azurewebsites.net/api/v1/Index|action: GetAll
ngohungphuc commented 5 years ago

cc @AbelianKraun How to fix this

services.AddAutoMapper(config => config.ValidateInlineMaps = false);