Реализовать обработку для ContextCreating
события и установить MergeOption
для ObjectSet<T>
:
public partial class YourPage : System.Web.UI.Page
{
...
protected void EntityDataSource_ContextCreating(object sender,
EntityDataSourceContextCreatingEventArgs e)
{
e.Context = new YourContext(); // EntityDataSource handles disposing
e.Context.YourObjectSet.MergeOption = MergeOption.NoTracking;
}
}
И в разметке использовать:
<asp:EntityDataSource ... OnContextCreating="EntityDataSource_ContextCreating" />