Create, delete and update problem

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
imre.dudas
Posts: 18
Joined: Thu 11 Mar 2010 20:36

Create, delete and update problem

Post by 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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by 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.

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

Post by 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.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by 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?

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

Post by 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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by 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

Post by 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.

Post Reply