问题描述
**我最近刚开始从事Entity Framework项目,我讨厌它,所以请原谅我不喜欢这项技术,但在我看来这不是一个好方法,因为它会产生太多的SQL调用对于最简单的负载; end Entity Framework rant **
我修改了一个使用Id字段作为另一个表的主键的表;被称为'Id'的字段现在称为TestSetupID,我添加的新字段现在称为ID,是一个标识字段。
延迟加载(我讨厌的另一件事) EF)停止了对这个属性的工作。
EF生成的SQL如下:
SELECT
[Extent1]。[Id] AS [Id],
[Extent1]。[SSTempGround] AS [SSTempGround],
[Extent1]。[SSTempAmbient] AS [SSTempAmbient],
[Extent1]。[BleedCall] AS [BleedCall],
[Extent1]。[BleedIncrement] AS [BleedIncrement],
[Extent1]。[ShowTesttoYield] AS [ShowTesttoYield],
[Extent1]。[CountTolerance] AS [CountTolerance],
[Extent1]。[VolumeReleased] AS [VolumeReleased],
[Extent1]。[PressureReduced] AS [PressureReduced],
[Extent1]。[PumpEfficiency] AS [PumpEfficiency]
FROM [dbo]。[DefaultValueTests] AS [Extent1]
WHERE [Extent1]。[Id] = @ EntityKeyValue1
- EntityKeyValue1:'1133'(Type = Int32,IsNullable = false)
- 执行时间为12/29 / 2015 1:52:34 PM -06:00
- 在1 ms内完成,结果:SqlDataReader
错误的部分是:
WHERE [Extent1]。[Id] = @ EntityKeyValue1;这应该是WHERE [Extent1]。[TestSetupID] = @ EntityKeyValue1;
如何告诉Entity Framework使用新字段。我在数据库中设置关系如下:
我认为这是正确的;是否有一些地方EF存储此关系缓存到错误的值?
谢谢,
-
漂浮很难;显示其他人真的很难。
** I recently started working on Entity Framework project, and I hate it, so please forgive me for not liking this technology, but it is not a good approach in my opinion as it makes too many SQL calls for the simplest loads; end Entity Framework rant **
I modified a table that was using the Id field to be the primary key from another table; the field that was called 'Id' is now called TestSetupID, and a new field I added that is now called ID, is an Identity field.
The lazy loading (another thing I hate about EF) stopped working on this property.
The SQL Generated by EF is as follows:
SELECT
[Extent1].[Id] AS [Id],
[Extent1].[SSTempGround] AS [SSTempGround],
[Extent1].[SSTempAmbient] AS [SSTempAmbient],
[Extent1].[BleedCall] AS [BleedCall],
[Extent1].[BleedIncrement] AS [BleedIncrement],
[Extent1].[ShowTesttoYield] AS [ShowTesttoYield],
[Extent1].[CountTolerance] AS [CountTolerance],
[Extent1].[VolumeReleased] AS [VolumeReleased],
[Extent1].[PressureReduced] AS [PressureReduced],
[Extent1].[PumpEfficiency] AS [PumpEfficiency]
FROM [dbo].[DefaultValueTests] AS [Extent1]
WHERE [Extent1].[Id] = @EntityKeyValue1
-- EntityKeyValue1: '1133' (Type = Int32, IsNullable = false)
-- Executing at 12/29/2015 1:52:34 PM -06:00
-- Completed in 1 ms with result: SqlDataReader
The part that is wrong is this:
WHERE [Extent1].[Id] = @EntityKeyValue1; this should now be WHERE [Extent1].[TestSetupID] = @EntityKeyValue1;
How do I tell Entity Framework to use the new field. I have the relationship setup in the database as follows:
It looks to me like this is correct; is there some place EF stores this relationship that is cached to the wrong values?
Thank you,
--
To levitate is hard; showing someone else is really hard.
这篇关于Entity Framework在哪里存储对象之间的关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!