Linq to SQL exception using sdf file

I created a project with a local SDF database file and am trying to access it using the LINQ To SQL file (".dbml"). I used the connection string provided by the sdf file and may trigger a problem with the problem:

thisDataContext = new MyDataContext(GetConnectionString()); 

However, when I try to access any information from it, for example

 var collection = (from MyObject p in thisDataContext.MyTable select p); 

I get an 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 am compiling something similar for SQL 2005 CE and a fix has been released, but I would have thought that the fix was fixed in this version before release.

Does anyone know a fix for this?

thanks

+4
source share
1 answer

Get rid of "dbo" in the attributes of the table of objects created by Linq to Sql

eg:.

 [Table(Name="dbo.Orders")] class Order { } 

Change this to:

 [Table(Name="Orders")] class Order { } 
+10
source

Source: https://habr.com/ru/post/1303502/


All Articles