简体   繁体   English

实体6数据库更改未更新到Db表

[英]Entity 6 Database change are not being updated to Db table

private void btnLoadPriceList_Click(object sender, EventArgs e)
{

        using (PriceUpdaterSQLEntities1 context = new PriceUpdaterSQLEntities1())
        {
            context.PRICE_LIST.RemoveRange(context.PRICE_LIST.Where(x => x.PRICE_ID != null));
            context.SaveChanges();
        }
}

I'm new to Entity framework and would like to know why my delete operation is not being updated to my SQL table in localDB? 我是实体框架的新手,想知道为什么我的删除操作没有更新到localDB中的SQL表?

I need to delete every record in the PRICE_LIST table before refilling it with new records. 我需要先删除PRICE_LIST表中的每条记录,然后再用新记录填充它。 PRICE_ID is the PK and cannot be null, which is why I queried for not null. PRICE_ID是PK,不能为null,这就是为什么我查询不为null的原因。 The code runs without errors, but nothing in the table is actually deleted. 该代码运行没有错误,但实际上表中的任何内容都没有删除。 I've done a lot of reading and don't understand what I'm doing wrong here. 我读了很多书,不明白我在做什么错。 I've rebuilt the Entity Model already, so I'm sure its not the connection string. 我已经重建了实体模型,所以我确定它不是连接字符串。

I just went with the old SqlConnection and SqlCommand objects to get things working. 我只是使用旧的SqlConnection和SqlCommand对象来使事情工作。 Problem solved. 问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM