我已经建立了一个SDF本地数据库文件的项目,并试图使用LINQ To SQL(“.dbml”)文件来访问它。 我已经使用了由sdf文件提供的连接字符串,并且可以实例化对象而不出现问题:
thisDataContext = new MyDataContext(GetConnectionString());但是,每当我尝试访问它的任何信息,例如
var collection = (from MyObject p in thisDataContext.MyTable select p);我得到的错误 -
“表名无效[令牌行号(如已知)= 2,令牌行偏移量(如已知)= 14,表名= Person]”
我正在使用Visual Studio 2008 SP1 .Net 3.5和SQL 2008 CE。
我收集了类似SQL 2005 CE发布的一个类似问题,并发布了一个修补程序,但我认为修复程序在发布之前会在此版本中得到修复。
有谁知道这个的修复?
谢谢
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
最满意答案
摆脱Linq to Sql创建的对象的Table属性中的“dbo”
例如:
[Table(Name="dbo.Orders")] class Order { }将其更改为:
[Table(Name="Orders")] class Order { }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 { }更多推荐
发布评论