views:

104

answers:

2

I guess this is a continuation of the last question I asked: http://stackoverflow.com/questions/2587542/bulk-insert-and-update-with-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). Any ideas what to check?

My app.config looks like:

<?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

+4  A: 

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...

Mike
Voila! There they are. Now, why won't it connect to where my connection string points instead of the Bin/Debug version? When I go to release this, what should I do to make sure it works?
Keith Barrows
@Keith It will work, the database that you are looking at is the database that is in your project folder, but a database file gets created in the debug folder separate from it. I don't know why, but I spent about 3 days researching this because I had the same problem in one of my projects...When you go to Deploy it, it will use one database file.
Mike
+1  A: 

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();
DShultz
If you follow the link I supplied the code is there (though it has since altered just a little bit). In essence, what you wrote is correct.
Keith Barrows
The error you mentioned in your prior post ("Unable to update the EntitySet 'ImportDoorAccess' because it has a DefiningQuery and no element exists in the element to support the current operation.") is thrown when the backing db table for the entity has no primary key specified. Does the database table ImportDoorAccess have a primary key column specified? If so is it an identity column?
DShultz
After getting that last question answered it does have a PK defined. Not an identity column though but rather a 2 column key on date and badge number. That is now working fine. With the other answer listed here I believe I have it solved. I appreciate your time and effort in helping me!
Keith Barrows