VS 2013 Lightswitch new record creation with identity field

asp.net-web-api2 entity-framework-6 odata visual-studio-2013 visual-studio-lightswitch

Question

I have a very basic testbed Lightswitch 2013 application, using an OData data source via Web API 2 and beyond that Entity Framework 6. The table in question has an auto-incrementing id field which is the primary key.

All is good in the sense that I can view data and update existing entries via the Lightswitch HTML Client. I can't create a new entry though, and I'm not sure how to handle this 'id' field. Basically as I understand it, it must be there in the Lightswitch table because it's obviously needed to update existing entries. For new entries I don't want to supply it because the database backend will just pick the next number. I have verified via Fiddler that I can create a new entry via OData and a POST without supplying a value for 'id', so how do I make Lightswitch ignore it ?

1
0
4/11/2014 3:35:29 PM

Accepted Answer

When you create Lightswitch entites, Lightswitch creates the id column in your table and sets it to auto increment therefore SQL is handling it, not the Lightswitch framework. Therefore if your POST via OData does the job then in my mind it should be ok.

1
4/12/2014 4:36:54 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow