Create, delete and update problem

Create, delete and update problem

Postby imre.dudas » Wed 21 Jul 2010 15:36

Hello,


I generated DataContext models from PostgreSQL database with Entity Developer new version. I can't insert, update and delete all of my tables in my program.

AuthorizationDataContext dc = new AuthorizationDataContext(connectString);
FirstChars f = new FirstChars();
...
dc.FirstChars.InsertOnSubmit(f);

And give me an exception:
System.InvalidOperationException: Can't perform Create, Update or Delete operations on 'Table(FirstChars)' because it is read-only or does not have identity members.
Devart.Data.Linq.Table.l()
Devart.Data.Linq.Table.c(Object A_0, Boolean A_1)
Devart.Data.Linq.Table`1.InsertOnSubmit(TEntity entity)

FirstChars is a simple table with three character varring fields: FirstThreeCharacters, SoftwareName, SoftwareVersion.

The role that i used in ConnectString have got privileges these operations in database.

Best Regards:
Imre
imre.dudas
 
Posts: 18
Joined: Thu 11 Mar 2010 20:36

Postby AndreyR » Thu 22 Jul 2010 15:38

Please check that your FirstChars entity has an Entity Key defined. This is usally a reason for such errors. Entities in LINQ to SQL should have Entity Keys defined to perform CUD operations with them.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby imre.dudas » Thu 22 Jul 2010 16:32

Thank you. It's ok.

If i remember good, in the last versions, entity key checked automatically.
imre.dudas
 
Posts: 18
Joined: Thu 11 Mar 2010 20:36

Postby AndreyR » Mon 26 Jul 2010 14:22

Could you please post here the script of the table you have encountered an error with the wrong Entity Key generation?
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby imre.dudas » Sat 31 Jul 2010 18:50

AndreyR wrote:Could you please post here the script of the table you have encountered an error with the wrong Entity Key generation?


I created a test on my server, and create a model. You can access to my database with this model. It's a simple test, but the entity key is false default.
The table creation SQL script is
create table testtable
(
test_id serial,
test_note varchar(100)
);

http://dl.dropbox.com/u/3968115/Test.zip

Regards:
Imre
imre.dudas
 
Posts: 18
Joined: Thu 11 Mar 2010 20:36

Postby AndreyR » Mon 02 Aug 2010 16:15

Thank you for the report, we are investigating the reasons of this issue.
I will notify you about the results of our investigation.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby AndreyR » Fri 06 Aug 2010 14:08

This behaviour is designed. Unlike Entity Framework, LINQ to SQL Entity does not need to have Entity Key by default.
In Entity Framework Entity Key will be inferred automatically form not-nullable columns.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to LinqConnect (LINQ to SQL support)