dotConnect 4.9.152 does't gen. EF Model for functions

dotConnect 4.9.152 does't gen. EF Model for functions

Postby jamesmuriithi » Tue 17 Aug 2010 12:43

I am currently writing an application that uses MS EntityFramework (EF) to retrieve data from a PostgreSQL v8.4 data store.

I created a public function in my PostgreSQL v8.4 database and attempted to generate an Entity Frameowrk Data Model using the Visual Studio 2010 IDE. I was unable to due to the following error

"Unable to generate the model because of the following exception: 'An error occurred while executing the command definition. See the inner exception for details. Column 'C4' is read only." (I am unable to obtain the details of the inner exception)

Please advise.
jamesmuriithi
 
Posts: 5
Joined: Mon 16 Aug 2010 19:54

Postby AndreyR » Tue 17 Aug 2010 13:56

Could you please post the DDL script of the function (including the objects the function depends on) here?
As an alternative, send the script to support * devart * com (subject "EF: Function & readonly column").
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby jamesmuriithi » Tue 17 Aug 2010 14:34

Sorry about that. Here it the script

CREATE TABLE "MyTable"
(
"Id" INT NOT NULL,
"Name" character varying(50) NOT NULL,
"Description" character varying(50) NOT NULL
)
WITH (
OIDS=FALSE
);


CREATE OR REPLACE FUNCTION "RetrieveMyTable"() RETURNS SETOF "MyTable" AS
$BODY$
DECLARE returnValue "MyTable"%rowType;
BEGIN
FOR returnValue IN SELECT * FROM "MyTable"
LOOP
RETURN NEXT returnValue ; -- return current row of SELECT
END LOOP;
RETURN;
END
$BODY$
LANGUAGE 'plpgsql' ;


When I try to generate the Entity Framework Object Context Model, here is the error I get
" Unable to generate the model because of the following exception: 'An error occurred while executing the command definition. See the inner exception for details.
Column 'C4' is read only.
'."
jamesmuriithi
 
Posts: 5
Joined: Mon 16 Aug 2010 19:54

Postby AndreyR » Wed 18 Aug 2010 11:50

I recommend you to add a Primary Key to your table, Entity Framework requires entity to have Entity Key.
However, the problem with the function is reproducible anyway.
We are investigating the issue.
Here is a workaround:
1. Add a Devart Entity model to your project.
2. Go to Database Explorer and drop the MyTable entity on the designer surface.
3. Drop the RetreiveMyTable procedure on the designer surface. You will receive an error.
4. Go to the Moder Designer, notice the function marked as erroneous. Edit the properties of this function: set Composable to false, and Concealed to true.
5. Drop the procedure from the Model.Store to the designer surface. Then you will be asked about retreiving metadata. You can either allow it or restrict (in the first case you will have a RetreiveMyTableResult complex type added to model, the return type of the function will be set to it automatically).
6. Change the Return Type of the generated method (Model Explorer->Methods->Retreivemytable->Properties) to the MyTable.
You are done. The method is now usable.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby jamesmuriithi » Wed 18 Aug 2010 18:29

Thanks. The ".edml" file seems to work better than the ".edmx" file
jamesmuriithi
 
Posts: 5
Joined: Mon 16 Aug 2010 19:54

Postby AndreyR » Tue 02 Nov 2010 11:32

The problem with .edmx files is fixed in the upcoming build.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to dotConnect for PostgreSQL