Convert DBContext to ObjectContext for use with GridView

前端 未结 3 1130
甜味超标
甜味超标 2020-11-30 04:49

I have a webforms project using EF codefirst to persist data. I\'d like to use a GridView and EntityDataSource, in order to save writing CRUD. Is this possible?

Can

3条回答
  •  既然无缘
    2020-11-30 05:27

    Try this one ->

    protected void OrdersDataSource_ContextCreating(object sender, EntityDataSourceContextCreatingEventArgs e)  
    {   
        var context = new YourContext();
        e.Context = ((IObjectContextAdapter)context).ObjectContext;
    }
    

提交回复
热议问题