SCM

[#1011343] Exception when calling stored procedures from within entity framework

View Trackers | Bugs | Download .csv | Monitor

Date:
2013-07-11 21:46
Priority:
3
State:
Open
Submitted by:
enuhtac enuhtac (enuhtac)
Assigned to:
Nobody (None)
Npgsql Version:
2.0.12beta
Category:
None
Group:
None
Resolution:
None
Summary:
Exception when calling stored procedures from within entity framework

Detailed description
Background
=========
Using the Microsoft Entity Framework and the provided tool "Edmgen" it is possible to automatically generate database access code from the three files comprising an entity data model (ssdl, csdl, msl). This includes wrapper code stored procedures.

Problem
======
When using entity framework in conjunction with Npgsql v2.0.12 calling these wrapper functions cause the following exception to the thrown:

System.Data.EntityCommandCompilationException: "An error occurred while preparing the command definition. See the inner exception for details."

With the inner exception:

System.ArgumentException: "Value does not fall within the expected range."

Probable cause
===========
I could trace this exception down to the method "NpgsqlServices.TranslateCommandTree" which builds the actual SQL code to call the stored procedure. When this method is called the passed value for parameter "commandTree" is of type "System.Data.Common.CommandTrees.DbFunctionCommandTree". This type is not convered by the implementation of "TranslateCommandTree", instead the exception mentioned above is thrown.

Used Software Versions
=================
Npgsql 2.0.12.1
.NET Framework 4.5.50709
Visual Studio Express 2012 for Windows Desktop 11.0.60610.01 Update 3

References
========
* http://pgfoundry.org/forum/message.php?msg_id=1020766&group_id=1000140
* http://stackoverflow.com/questions/16497672/entity-framework-and-postgresql-exception-when-calling-stored-procedure

Attachments
=========
I'm attaching a test project to reproduce the described error.


Followup

Message
Date: 2013-12-16 20:47
Sender: Francisco Figueiredo jr.

We have some work done to add this functionality. You can check it here: https://github.com/npgsql/Npgsql/pull/129
Date: 2013-07-23 21:23
Sender: Francisco Figueiredo jr.

Just tried it and you analysis is correct. Npgsql is missing support for calling functions. We will have to implement it. Sorry for that.
Date: 2013-07-12 01:14
Sender: Francisco Figueiredo jr.

Great!

Thanks for your test case, I'll have a look at it and see what the problem is.

Attached Files:

Attachments:
npgsqlTest.zip

Changes:

Field Old Value Date By
File Added808: npgsqlTest.zip2013-07-11 21:46enuhtac
Powered By FusionForge