You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
REPORTED ON:
REPORTED BY:
Oct 13, 2015 at 3:25 AM
samunro
The ColumnAttribute allows for property names that do not match the columns in the database to be mapped correctly in an Entity Framework Code First model.
This attribute does not appear to be respected by codefirstfunctions.
As an example, this is an error that I saw.
System.Data.Entity.Core.EntityCommandExecutionException: The data reader is incompatible with the specified '<Class Name>'. A member of the type, '<Property Name>', does not have a corresponding column in the data reader with the same name.
at System.Data.Entity.Core.Query.InternalTrees.ColumnMapFactory.GetMemberOrdinalFromReader(DbDataReader storeDataReader, EdmMember member, EdmType currentType, Dictionary2 renameList)
at System.Data.Entity.Core.Query.InternalTrees.ColumnMapFactory.GetColumnMapsForType(DbDataReader storeDataReader, EdmType edmType, Dictionary2 renameList)
at System.Data.Entity.Core.Query.InternalTrees.ColumnMapFactory.CreateColumnMapFromReaderAndType(DbDataReader storeDataReader, EdmType edmType, EntitySet entitySet, Dictionary2 renameList)
at System.Data.Entity.Core.Query.InternalTrees.ColumnMapFactory.CreateFunctionImportStructuralTypeColumnMap(DbDataReader storeDataReader, FunctionImportMappingNonComposable mapping, Int32 resultSetIndex, EntitySet entitySet, StructuralType baseStructuralType)
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.FunctionColumnMapGenerator.System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.IColumnMapGenerator.CreateColumnMap(DbDataReader reader)
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.CreateColumnMap(DbDataReader storeDataReader, Int32 resultSetIndex)
at System.Data.Entity.Core.Objects.ObjectContext.MaterializedDataRecord[TElement](EntityCommand entityCommand, DbDataReader storeReader, Int32 resultSetIndex, ReadOnlyCollection1 entitySets, EdmType[] edmTypes, ShaperFactory1 shaperFactory, MergeOption mergeOption, Boolean streaming)
at System.Data.Entity.Core.Objects.ObjectContext.CreateFunctionObjectResult[TElement](EntityCommand entityCommand, ReadOnlyCollection1 entitySets, EdmType[] edmTypes, ExecutionOptions executionOptions)
at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass471.<ExecuteFunction>b__46()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass471.<ExecuteFunction>b__45()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func1 operation)
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, ExecutionOptions executionOptions, ObjectParameter[] parameters)
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, MergeOption mergeOption, ObjectParameter[] parameters)
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, ObjectParameter[] parameters)...
Adding the ColumnAttribute to the property referenced in the error did not resolve the issue.
I have this problem when i call a table valued function that return these entities :
public class Location
{
[Column("IDX_PARENT")]
public int ParentId { get; set; }
public int Level { get; set; }
public string Root { get; set; }
[Column("IDX_LOCALISATION")]
public int Id { get; set; }
}
[DbFunction("EntityDbContext", "GetChildrenLocations")]
public IQueryable<Location> GetChildrenLocations(int rootId)
{
return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<ChildLocation>(string.Format("[{0}].[GetChildrenLocations](@Root)", this.GetType().Name), new ObjectParameter("Root", rootId));
}
There is a mapping exception :
Invalid column name 'Id', Invalid column name 'ParentId'
Is ColumnName attribute will be supported in the next release?
Ported from https://codefirstfunctions.codeplex.com/workitem/15
REPORTED ON:
REPORTED BY:
Oct 13, 2015 at 3:25 AM
samunro
The ColumnAttribute allows for property names that do not match the columns in the database to be mapped correctly in an Entity Framework Code First model.
This attribute does not appear to be respected by codefirstfunctions.
As an example, this is an error that I saw.
Adding the ColumnAttribute to the property referenced in the error did not resolve the issue.
moozzyk wrote Oct 14, 2015 at 12:47 PM [x]
Related http://codefirstfunctions.codeplex.com/discussions/645574
The text was updated successfully, but these errors were encountered: