The specified cast from a materialized 'System.Data.Entity.Core.Objects.MaterializedDataRecord' type to the 'Test.SomeType' type is not valid.


I've got subj message for TVF import using this library. I have an Entity Type SomeType and this method:
        [DbFunction("DataContextBase", "SomeData")]
        public virtual IQueryable<SomeType> SomeData(Guid? applicationId)
            var applicationIdParameter = applicationId.HasValue ?
                new ObjectParameter("ApplicationId", applicationId) :
                new ObjectParameter("ApplicationId", typeof(Guid));

            return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<SomeType>("[DataContextBase].[SomeData](@ApplicationId);
EF version:
Closed Oct 24, 2016 at 3:24 AM by moozzyk
Could not repro - requested details not provided.


moozzyk wrote Sep 28, 2016 at 5:05 PM

Please provide a full working repro. What you provided would not even compile (missing " CreateQuery parameter). I also don't see a parameter for @ApplicationId being passed to CreateQuery (I suppose you want to pass applicationIdParameter). Finally please provide the full stack trace. As reported I am not sure where the error is really happening.