Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Visual Studio Entity Framework cannot detect Primary Key

5 posts in General Discussion Last posting was on 2012-11-15 14:48:36.0Z
Jim Thomas Posted on 2012-11-13 20:16:37.0Z
Sender: 3e1b.50a2a3a7.1804289383@sybase.com
From: Jim Thomas
Newsgroups: sybase.public.ase.general
Subject: Visual Studio Entity Framework cannot detect Primary Key
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <50a2aaa5.40b3.1681692777@sybase.com>
NNTP-Posting-Host: 172.20.134.41
X-Original-NNTP-Posting-Host: 172.20.134.41
Date: 13 Nov 2012 12:16:37 -0800
X-Trace: forums-1-dub 1352837797 172.20.134.41 (13 Nov 2012 12:16:37 -0800)
X-Original-Trace: 13 Nov 2012 12:16:37 -0800, 172.20.134.41
Lines: 9
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:31485
Article PK: 74374

I am using ASE 15.7 and Visual Studio. I can create an
Entity Framework model and read Sybase tables using LINQ in
C#. However, all tables added to the model are brought in as
readonly because Entity Framework cannot detect the table's
primary key. But the primary key does exist and is shown in
sp_help. I have also written an iSql query against
sysobjects to prove to myself the primary key is defined
(it's type=1 in syskeys). What do I need to do to make these
tables updateable?


Rob V Posted on 2012-11-13 20:36:24.0Z
From: Rob V <rob@sypron.nl>
Reply-To: rob@sypron.nl
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: Visual Studio Entity Framework cannot detect Primary Key
References: <50a2aaa5.40b3.1681692777@sybase.com>
In-Reply-To: <50a2aaa5.40b3.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <50a2af48$1@forums-1-dub>
Date: 13 Nov 2012 12:36:24 -0800
X-Trace: forums-1-dub 1352838984 172.20.134.152 (13 Nov 2012 12:36:24 -0800)
X-Original-Trace: 13 Nov 2012 12:36:24 -0800, vip152.sybase.com
Lines: 34
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:31486
Article PK: 74375


On 13-Nov-2012 21:16, Jim Thomas wrote:
> I am using ASE 15.7 and Visual Studio. I can create an
> Entity Framework model and read Sybase tables using LINQ in
> C#. However, all tables added to the model are brought in as
> readonly because Entity Framework cannot detect the table's
> primary key. But the primary key does exist and is shown in
> sp_help. I have also written an iSql query against
> sysobjects to prove to myself the primary key is defined
> (it's type=1 in syskeys). What do I need to do to make these
> tables updateable?
>

The question is of course exactly how it recognizes a primary key.
Does "sp_pkeys your-table-name" (execute in ASE with isql) show the
right informations?

--
HTH,

Rob V.
-----------------------------------------------------------------
Rob Verschoor

Certified Professional DBA for Sybase ASE, IQ, Replication Server

Author of Sybase books (order online at www.sypron.nl/shop):
"Tips, Tricks & Recipes for Sybase ASE"
"The Complete Sybase IQ Quick Reference Guide"
"The Complete Sybase ASE Quick Reference Guide"
"The Complete Sybase Replication Server Quick Reference Guide"

rob@NO.SPAM.sypron.nl | www.sypron.nl | Twitter: @rob_verschoor
Sypron B.V., The Netherlands | Chamber of Commerce 27138666
-----------------------------------------------------------------


Jim Thomas Posted on 2012-11-13 22:54:27.0Z
Sender: 3e1b.50a2a3a7.1804289383@sybase.com
From: Jim Thomas
Newsgroups: sybase.public.ase.general
Subject: Re: Visual Studio Entity Framework cannot detect Primary Key
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <50a2cfa3.4efd.1681692777@sybase.com>
References: <50a2af48$1@forums-1-dub>
NNTP-Posting-Host: 172.20.134.41
X-Original-NNTP-Posting-Host: 172.20.134.41
Date: 13 Nov 2012 14:54:27 -0800
X-Trace: forums-1-dub 1352847267 172.20.134.41 (13 Nov 2012 14:54:27 -0800)
X-Original-Trace: 13 Nov 2012 14:54:27 -0800, 172.20.134.41
Lines: 43
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:31488
Article PK: 74376


> On 13-Nov-2012 21:16, Jim Thomas wrote:
> > I am using ASE 15.7 and Visual Studio. I can create an
> > Entity Framework model and read Sybase tables using LINQ
> > in C#. However, all tables added to the model are
> > brought in as readonly because Entity Framework cannot
> > detect the table's primary key. But the primary key does
> > exist and is shown in sp_help. I have also written an
> > iSql query against sysobjects to prove to myself the
> > primary key is defined (it's type=1 in syskeys). What do
> > I need to do to make these tables updateable?
> >
>
> The question is of course exactly how it recognizes a
> primary key. Does "sp_pkeys your-table-name" (execute in
> ASE with isql) show the right informations?
>
> --
> HTH,
>
> Rob V.
> ----------------------------------------------------------
> ------- Rob Verschoor
>
> Certified Professional DBA for Sybase ASE, IQ, Replication
> Server
>
> Author of Sybase books (order online at
> www.sypron.nl/shop): "Tips, Tricks & Recipes for Sybase
> ASE" "The Complete Sybase IQ Quick Reference Guide"
> "The Complete Sybase ASE Quick Reference Guide"
> "The Complete Sybase Replication Server Quick Reference
> Guide"
>
> rob@NO.SPAM.sypron.nl | www.sypron.nl | Twitter:
> @rob_verschoor Sypron B.V., The Netherlands | Chamber of
> Commerce 27138666
> ----------------------------------------------------------
> -------

Thats a good suggestion cause sp_helpkey shows the key type
as primary (which Entity Framework does not recognize) but
sp_pkeys does not show a primary key. In summary, if it does
not show up with sp_pkeys Entity Framework will not work.


Jim Thomas Posted on 2012-11-13 22:46:06.0Z
Sender: 4e01.50a2ccf5.1804289383@sybase.com
From: Jim Thomas
Newsgroups: sybase.public.ase.general
Subject: Re: Visual Studio Entity Framework cannot detect Primary Key
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <50a2cdae.4e35.1681692777@sybase.com>
References: <50a2aaa5.40b3.1681692777@sybase.com>
NNTP-Posting-Host: 172.20.134.41
X-Original-NNTP-Posting-Host: 172.20.134.41
Date: 13 Nov 2012 14:46:06 -0800
X-Trace: forums-1-dub 1352846766 172.20.134.41 (13 Nov 2012 14:46:06 -0800)
X-Original-Trace: 13 Nov 2012 14:46:06 -0800, 172.20.134.41
Lines: 16
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:31487
Article PK: 74381


> I am using ASE 15.7 and Visual Studio. I can create an
> Entity Framework model and read Sybase tables using LINQ
> in C#. However, all tables added to the model are brought
> in as readonly because Entity Framework cannot detect the
> table's primary key. But the primary key does exist and is
> shown in sp_help. I have also written an iSql query
> against sysobjects to prove to myself the primary key is
> defined (it's type=1 in syskeys). What do I need to do to
> make these tables updateable?

Solution: It appears not all flavors of defining a primary
key are 'acceptable' to Entity Framework. We were using
sp_primarykey to define primary keys which did not work.
However, when I use the attribute 'Primary Key' on a column
or at the end of the create table statement as ',primary key
(...)' then Entity Framework recognizes the primary key.


primarykey Posted on 2012-11-15 14:48:36.0Z
Sender: 565a.50a4ffd2.1804289383@sybase.com
From: primarykey
Newsgroups: sybase.public.ase.general
Subject: Re: Visual Studio Entity Framework cannot detect Primary Key
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <50a500c4.56a7.1681692777@sybase.com>
References: <50a2cdae.4e35.1681692777@sybase.com>
NNTP-Posting-Host: 172.20.134.41
X-Original-NNTP-Posting-Host: 172.20.134.41
Date: 15 Nov 2012 06:48:36 -0800
X-Trace: forums-1-dub 1352990916 172.20.134.41 (15 Nov 2012 06:48:36 -0800)
X-Original-Trace: 15 Nov 2012 06:48:36 -0800, 172.20.134.41
Lines: 13
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:31493
Article PK: 74382

Key here is sp_primarykey:
sp_primarykey does not enforce referential integrity
constraints; use the primary key clause of the create table
or alter table command to enforce a primary key relationship

> Solution: It appears not all flavors of defining a primary
> key are 'acceptable' to Entity Framework. We were using
> sp_primarykey to define primary keys which did not work.
> However, when I use the attribute 'Primary Key' on a
> column or at the end of the create table statement as '
> ,primary key (...)' then Entity Framework recognizes the
> primary key.