Search code examples
.netasp.netentity-framework-4linqdatasource

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


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!


Solution

  • 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.