Efcore: Property '...' is not defined for type 'Microsoft.EntityFrameworkCore.Storage.ValueBuffer'

Created on 25 Nov 2016  路  3Comments  路  Source: dotnet/efcore

Steps to reproduce

Download the source from the Automapper project (https://github.com/AutoMapper/AutoMapper).
Add following file EricRelationsWithForeignKeySimplified.zip
to the project IntegrationTests.Net4. It is working with EF 6.
Set a breakpoint on line 31 and run the code. It will give you a correct result.

Add the project IntegrationTests.NetCore from the attachment zip. It is the same project, but now for EF Core.
IntegrationTests.NetCore.zip
You will find the same file and same code. Set also a breakpoint on the same line and run the code.

The issue

Running the code will throw following error:


Test Name: IntegrationTests.NetCore.EricRelationsWithForeignKeySimplified.Should_expand_collections_items
Test FullName: IntegrationTests.NetCore.EricRelationsWithForeignKeySimplified.Should_expand_collections_items
Test Source: D:\DevTree\MyTestProjects\AutoMapper-master\src\IntegrationTests.NetCore\EricRelationsWithForeignKeySimplified.cs : line 42
Test Outcome: Failed
Test Duration: 0:00:00

Result StackTrace:
at System.Linq.Expressions.Expression.Property(Expression expression, PropertyInfo property)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalProjectionExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitMemberAssignment(MemberAssignment node)
at System.Linq.Expressions.ExpressionVisitor.VisitT
at System.Linq.Expressions.ExpressionVisitor.VisitMemberInit(MemberInitExpression node)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalProjectionExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitConditional(ConditionalExpression node)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalProjectionExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitMemberAssignment(MemberAssignment node)
at System.Linq.Expressions.ExpressionVisitor.VisitT
at System.Linq.Expressions.ExpressionVisitor.VisitMemberInit(MemberInitExpression node)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalProjectionExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitSelectClause(SelectClause selectClause, QueryModel queryModel)
at Remotion.Linq.Clauses.SelectClause.Accept(IQueryModelVisitor visitor, QueryModel queryModel)
at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitQueryModel(QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitQueryModel(QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryModelVisitor.VisitQueryModel(QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutorTResult
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQueryTResult
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCoreTResult
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass19_01.<CompileQuery>b__0() at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryTResult
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryTResult
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteTResult
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteTResult
at IntegrationTests.NetCore.EricRelationsWithForeignKeySimplified.Because_of() in D:\DevTree\MyTestProjects\AutoMapper-master\src\IntegrationTests.NetCore\EricRelationsWithForeignKeySimplified.cs:line 34
at AutoMapper.UnitTests.SpecBaseBase.MainSetup() in D:\DevTree\MyTestProjects\AutoMapper-master\src\IntegrationTests.NetCore\AutoMapperSpecBase.cs:line 35
at AutoMapper.UnitTests.SpecBase..ctor() in D:\DevTree\MyTestProjects\AutoMapper-master\src\IntegrationTests.NetCore\AutoMapperSpecBase.cs:line 71
at AutoMapper.UnitTests.NonValidatingSpecBase..ctor()
at AutoMapper.UnitTests.AutoMapperSpecBase..ctor()
at IntegrationTests.NetCore.EricRelationsWithForeignKeySimplified..ctor()
Result Message: Property 'System.String CategoryName' is not defined for type 'Microsoft.EntityFrameworkCore.Storage.ValueBuffer'


If I change following code

        public class TrainingCourseDto
        {
            public int CourseId { get; set; }
            public string CourseName { get; set; }
            public string IdentificationNumber { get; set; }

            public CategoryDto MainCategory { get; set; }
            public CategoryDto SubCategory { get; set; }
        }

to

        public class TrainingCourseDto
        {
            public int CourseId { get; set; }
            public string CourseName { get; set; }

            public string IdentificationNumber { get; set; }
            public Category MainCategory { get; set; }
            public Category SubCategory { get; set; }
        }

it is working...

First I thought about an error/bug in Automapper, not mapping correctly in this 'third' level, but the error speakes about the ValueBuffer, so I did the same test under EF6 and no problem there.

Further technical details

EF Core version: see project.json
Visual Studio version: VS 2015

closed-fixed type-bug

Most helpful comment

Is there a known possible workaround for this problem while waiting on the correction?

All 3 comments

Is there a known possible workaround for this problem while waiting on the correction?

@maumar @rowanmiller

Having same issue. Any news here?

Verified it's working fine in 2.0 preview.

Possible workaround with 1.1.1? :)

I can use 2.0 preview with a NetCoreApp 1.0 Console app, but not a ASP.NET Core app because of the preview dependencies that conflict with ASP.NET Core dependencies:

when I run the ASP.Net app, I get:

System.MissingMethodException: 'Method not found: 'System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.'

@maumar - wrong milestone for this? Or is this supposed to be closed?

Was this page helpful?
0 / 5 - 0 ratings