简体   繁体   中英

Sql query generated by entity framework contains [dbo] and is not returning any results

I am playing around a bit with entity framework 6.1.3 in combination with EntityFramework.SQLServerCompact 6.1.3 for SQL Server Compact 4.0. I got a database with a table named SingleEntities with a few basic columns. This table got 4 rows as testdata. When I try to retrieve all 4 rows with the following code:

var entities = context.SingleEntities.ToList();

No rows are returned and no error is shown. When I check the query this code is creating, I see the this query:

SELECT 
[Extent1].[Id] AS [Id], 
[Extent1].[FirstName] AS [FirstName], 
[Extent1].[LastName] AS [LastName], 
[Extent1].[BeginDate] AS [BeginDate], 
[Extent1].[EndDate] AS [EndDate]
FROM [dbo].[SingleEntities] AS [Extent1]

When I run this query directly on the database, I am getting this error:

Error Code: 80040E14 Message : The table name is not valid. [ Token line number (if known) = 7,Token line offset (if known) = 18,Table name = SingleEntities ] Minor Err.: 26100 Source : SQL Server Compact ADO.NET Data Provider Num. Par. : 7 Num. Par. : 18 Err. Par. : SingleEntities

When I remove the [dbo]. part in the query, the query gives me the result I want.

How can I tell entity framework not to add the [dbo]. part to the query? I tried to do this with an IDbCommandInterceptor but I still didn't get any result.

您正在查找错误数据库中的数据 - 请仔细检查您的连接字符串

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM