I've set up a project with an SDF local database file and am trying to access it using an LINQ To SQL (".dbml") file. I have used the connection string provided by the sdf file and can instanciate the object with out a problem:
thisDataContext = new MyDataContext(GetConnectionString());
However, whenever i try to access any information from it eg
var collection = (from MyObject p in thisDataContext.MyTable select p);
I get the error -
"The table name is not valid. [ Token line number (if known) = 2,Token line offset (if known) = 14,Table name = Person ]"
I am using Visual Studio 2008 SP1 .Net 3.5 and SQL 2008 CE.
I gather something similar happened for SQL 2005 CE and a Hotfix was released, but i would have thought the fix would have been fixed in this version before release.
Does anyone know the fix for this?
Thanks
Get rid of the "dbo" in the Table attributes on the objects created by Linq to Sql
e.g.:
[Table(Name="dbo.Orders")]
class Order
{
}
Change that to:
[Table(Name="Orders")]
class Order
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With