Can I get EnableUpdate and EnableDelete to work on an EF4 LinqDataSource?

浪尽此生 提交于 2019-12-12 05:44:42

问题


So I started using Linq-To-Sql about 2 years ago, but my company is pushing me to switch to Entity Framework v4. Don't want to get into the L2s vs EF arguments here, please just assume that I cannot switch back to L2S.

Anyway, in good ol' L2S, I'd define a gridview or listview, then a LinqdataSource with EnableUpdate=true, EnableDelete=true and EnableInsert=true. I'd assign the DataSourceID of teh gridview or listview to the ID of the linqdatasource and BAM! Instant CRUD.

With EF4 however, it seems that this automatic codeless CRUD is missing. From the Visual Studio 2010 Design screen, my Gridview Tasks window does NOT show "Enable Editing" or "Enable Deleting". These items used to appear in my L2S apps, and furthermore, when I manually add the EnableX=true properties to my LinqDataSource, I get an error when I attempt an update: "The data context used by LinqDataSource 'lds1' must extend DataContext when the Delete, Insert or Update operations are enabled."

So is there a way to make EF4 obey my EnableUpdate/Delete/Insert commands on the LinqDataSource?

Thanks!


回答1:


First of all LinqDataSource is component for Linq-to-Sql. You must use EntityDataSource to work on top of Entity Framework. It will probably solve your issue.



来源:https://stackoverflow.com/questions/4946399/can-i-get-enableupdate-and-enabledelete-to-work-on-an-ef4-linqdatasource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!