Hornet Dear Bernard

Dear, Dear Bernard

Entity Framework Error About Defining Query

leave a comment »

If you get a weird error in Entity Framework, waffling on about a DefiningQuery but no insert possible, then check the edmx XML. It is likely that the entity was a hidden join table, or perhaps a view and has changed. Edit the entity in the XML to resemble the other standard entities.

Example:
Before:

<EntitySet Name="ComponentVersionDeviceType" EntityType="OLTP.Store.ComponentVersionDeviceType" store:Type="Tables" store:Schema="dbo" store:Name="ComponentVersionDeviceType">

<DefiningQuery>SELECT       [ComponentVersionDeviceType].[ComponentVersionID] AS [ComponentVersionID],       [ComponentVersionDeviceType].[DeviceTypeID] AS [DeviceTypeID],       [ComponentVersionDeviceType].[Inserted] AS [Inserted]      FROM [dbo].[ComponentVersionDeviceType] AS [ComponentVersionDeviceType]</DefiningQuery>        </EntitySet>

After:

<EntitySet Name="ComponentVersionDeviceType" EntityType="OLTP.Store.ComponentVersionDeviceType" store:Type="Tables" Schema="dbo"/>

Advertisements

Written by bernardhornet

March 28, 2011 at 12:06 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: