1

最近我安装了 VS2012 并尝试重新制作我的旧 WPF 项目。在 VS2010 中,该代码工作并且 Datagrid 中的所有更新或新行通过实体模型保存在 DB 中。在 VS2012 中,数据库中未添加新行。

    MyEntities context = new MyEntities();

    public MainWindow()
    {
        InitializeComponent();

    }

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        var selected = from row in context.Sources
                       select row;
        Datagrid.ItemsSource = selected.ToList();
    }

    private void Button_Click_2(object sender, RoutedEventArgs e)
    {
        context.SaveChanges();
    }

为什么没有添加新行?

4

0 回答 0