Problems inserting records

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Cloud Applications
Post Reply
pattejam
Posts: 2
Joined: Wed 05 Feb 2014 00:54

Problems inserting records

Post by pattejam » Wed 05 Feb 2014 01:10

Using VS 2013, C#, Entity Framework 6.0.2, and dotconnect for salesforce 2.4.301.0.

I can seem to do all selects and updates I need, but when I create a new record I get "The key field 'Id' cannot have a value of null". I have tried all the options for StoreGeneratedPattern in this field's properties in the edmx, without success.

Do I need to do something more after I set this property? Seems like I am missing something obvious.

Thank you

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Problems inserting records

Post by Shalex » Wed 05 Feb 2014 13:11

You should set StoreGeneratedPattern=Identity for the Id property in SSDL (Store) part of your model: http://msdn.microsoft.com/en-us/library ... ttern.aspx.
pattejam wrote:I have tried all the options for StoreGeneratedPattern in this field's properties in the edmx, without success.
EDM Wizard/Designer (*.edmx) allows editing only CSDL part of the model in design time. You should open *.edmx with XML Editor and set StoreGeneratedPattern=Identity in SSDL.

We recommend you to use Entity Developer (Devart Entity Model, *.edml) instead of EDM Designer (ADO.NET Entity Data Model, *.edmx) because it is adjusted for working with Salesforce and has an advanced functionality: http://www.devart.com/entitydeveloper/ed-vs-edm.html. Additionally, Entity Developer adds registration of EF6-provider in app.config automatically and allows editing SSDL in design time.

pattejam
Posts: 2
Joined: Wed 05 Feb 2014 00:54

Re: Problems inserting records

Post by pattejam » Thu 06 Feb 2014 19:13

Shalex,

Thank you for the insight. I switched to the Devart Entity Model and that seems to fix the issue I was having. It has exposed another problem though.

Whenever I try to get Cases for a contact using:

Code: Select all

contact.Cases1__r
or

Code: Select all

var supportcase = (from i in db.Cases select i).FirstOrDefault();
it exceptions with:

Code: Select all

{"SQLite error\r\nnear \"CASE\": syntax error"}
With "Case" being a reserved word, is there a workaround for this?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Problems inserting records

Post by Shalex » Mon 10 Feb 2014 10:39

We have reproduced the issue and are investigating it. We will notify you about the result.

As a workaround, please do not add the Case table in a local cache: remove the C:\Users\YOUR_OS_USER_NAME\Application Data\*.db files (dotConnect for Salesforce will recreate them on the next connection.Open()), remove "Cache All=true;" from your connection string if any, and make sure that you do not add Case in the local cache explicitly (like conn.Cache.Create("CASE", 1, RefreshIntervalUnit.Hour, true);).

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Problems inserting records

Post by Shalex » Wed 25 Jun 2014 14:43

The bug quoting the CASE table when storing it in a local cache is fixed. We will notify you when the corresponding build of dotConnect for Salesforce is available for download.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Problems inserting records

Post by Shalex » Thu 26 Jun 2014 12:10

New build of dotConnect for Salesforce 2.4.412 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/salesf ... nload.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=38&t=29863.

Post Reply