I am having trouble using a .sdf database file with Ling2SQL. I am working with VS2010 on .NET 3.5. What I have done so far:
- Created sdf file and added tables and data (located in project folder)
Copied SQLMetal.exe and SqlMetal.exe.config to the project folder and called it with:
SQLMetal.exe database.sdf /dbml:DataOffline.dbml /namespace:CTcalc /pluralize
Added dbml file to the project (designer.cs is created)
Add new method to designer.cs
public DataOfflineDataContext() : base(global::CTcalc.Properties.Settings.Default.databaseOfflineConnectionString, mappingSource) { OnCreated(); }
Add connectionString to settings file (type:connectionString)
Data Source=|DataDirectory|\database.sdf
Using the connection:
using (DataOfflineDataContext dc = new DataOfflineDataContext()) lProtFunc = (from c in dc.ProtectionFunctions select c).ToList();
When debugging my project, I get an BadImageFormatException error with HRESULT: 0x8007000B
I have no idea how to fix it. Any help?
My fault was using the wrong .dll within my project.
I used
instead of
Now it is working!
You must install both the x86 and x64 runtimes on your x64 system - http://www.microsoft.com/download/en/details.aspx?id=5783