Reputation: 3912
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
Upvotes: 4
Views: 1822
Reputation: 103760
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
{
}
Upvotes: 10