简体   繁体   English

LINQ EF未保存到数据库

[英]LINQ EF not saving to database

I guess this is a continuation of the last question I asked: bulk insert and update with ADO.NET Entity Framework . 我想这是我问的最后一个问题的延续: 使用ADO.NET Entity Framework进行批量插入和更新

I am not getting any errors while doing inserts yet no data is actually going into my DB. 在执行插入操作时没有出现任何错误,但实际上没有数据进入我的数据库。 My DB is a SDF file (SQL CE). 我的数据库是一个SDF文件(SQL CE)。 Any ideas what to check? 有什么想法要检查吗?

My app.config looks like: 我的app.config看起来像:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
  </configSections>
  <connectionStrings>
    <add name="Lab_Use_Billing.Properties.Settings.LabUseConnectionString" 
         connectionString="Data Source=|DataDirectory|\Models\LabUse.sdf" 
         providerName="Microsoft.SqlServerCe.Client.3.5" />
    <add name="LabUseEntities" 
         connectionString="metadata=res://*/Models.LabUseEntities.csdl|res://*/Models.LabUseEntities.ssdl|res://*/Models.LabUseEntities.msl;
                           provider=System.Data.SqlServerCe.3.5;
                           provider connection string=&quot;Data Source=|DataDirectory|\Models\LabUse.sdf&quot;" 
         providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

TIA TIA

Let me guess, your DB is a local database on your computer? 让我猜猜,您的数据库是计算机上的本地数据库? Try looking in the project debug folder for a database and see if that has your changes... 尝试在项目调试文件夹中查找数据库,看看是否有您的更改...

Just add the debug database as a new connection in the server explorer and refresh to see if the changes are there... 只需在服务器资源管理器中将调试数据库添加为新连接,然后刷新以查看更改是否存在...

Can you post the code you are using to create the rows in the database? 您可以发布用于在数据库中创建行的代码吗?

I assume you're newing up an object context and then using something like: 我假设您要更新对象上下文,然后使用类似以下内容的方法:

        myContext.AddToWidgetSet(widget);
        myContext.SaveChanges();

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

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