In my page i'm using a GridView which has an Entiy Datasource and when i'm trying to update or delete a record i get this error
No key property values were found during an update or delete operation. Check to ensure that key properties specified as binding expressions are available to the data source.
I don't know what i'm doing wrong or what is missing please help me.
A table needs a primary key for the entityframe to know what records to change. Once you add the primary key right click on the entity designer and select update database
Is the primary key a single column? If it is try right clicking on the entity framework designer and select update model. Hopefully that will fix the mappings
Show us your model entities as well as your codes……Well,if possible,plz show us your real codes and debug you app and point out what's wrong with your codes?
From this statament I cannot see any things to do……But in my mind,I think if you use EntityFramework to bind to the GridView and enable CRUD,everything should be fine……So please have a try of that way。
kukikukac
Member
2 Points
4 Posts
Fail to update database with Entity Framework.
Apr 08, 2012 12:39 PM|LINK
In my page i'm using a GridView which has an Entiy Datasource and when i'm trying to update or delete a record i get this error
No key property values were found during an update or delete operation. Check to ensure that key properties specified as binding expressions are available to the data source.
I don't know what i'm doing wrong or what is missing please help me.
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: Fail to update database with Entity Framework.
Apr 08, 2012 12:41 PM|LINK
A table needs a primary key for the entityframe to know what records to change. Once you add the primary key right click on the entity designer and select update database
http://msdn.microsoft.com/en-us/library/aa933092(v=sql.80).aspx
Space Coast .Net User Group
kukikukac
Member
2 Points
4 Posts
Re: Fail to update database with Entity Framework.
Apr 08, 2012 12:51 PM|LINK
Hi Ken,
The table has a primary key and it can be seen in the entity designer as well but it still does not work.
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: Fail to update database with Entity Framework.
Apr 08, 2012 03:00 PM|LINK
Is the primary key a single column? If it is try right clicking on the entity framework designer and select update model. Hopefully that will fix the mappings
Space Coast .Net User Group
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Fail to update database with Entity Framework.
Apr 10, 2012 01:22 AM|LINK
Hello kukikukac:)
Show us your model entities as well as your codes……Well,if possible,plz show us your real codes and debug you app and point out what's wrong with your codes?
Reguards!
kukikukac
Member
2 Points
4 Posts
Re: Fail to update database with Entity Framework.
Apr 10, 2012 05:10 PM|LINK
Hi Decker Dong !
Actually, I found out that sorting the gridview caused the problem, I used the following statement :
GridView1.Sort("id", SortDirection.Ascending);
without this, I can update the database, however I really need to sort this GridView.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Fail to update database with Entity Framework.
Apr 11, 2012 01:04 AM|LINK
Hello again:)
From this statament I cannot see any things to do……But in my mind,I think if you use EntityFramework to bind to the GridView and enable CRUD,everything should be fine……So please have a try of that way。
Reguards!
kerry-jiang
Member
55 Points
13 Posts
Re: Fail to update database with Entity Framework.
Feb 07, 2013 06:28 AM|LINK
I have the same issue, deleting will be disabled after programming sorting.
Welcome to my ebook store
http://www.drivehq.com/folder/p43383.aspx