开发者

exception with Linq to SQL using sdf file

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 r开发者_如何学JAVAeleased, 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
{

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜