This project is read-only.

Problem inserting associated item with EFDAL, missing Audit fields on SP

Nov 16, 2010 at 2:37 PM

I am getting this error inserting an item into an assocative table with EFDAL

{"Procedure or function 'gen_Group_EmployeeInsert' expects parameter '@created_date', which was not supplied."}

When I looked at the MSL file I can see that the audit fields are not included in the list of parameters:

<InsertFunction FunctionName="ND.Time.EFDAL.Store.gen_Group_EmployeeInsert">
	<EndProperty Name="GroupList">
		<ScalarProperty Name="Id" ParameterName="GroupId" />
	</EndProperty>
	<EndProperty Name="EmployeeList">
		<ScalarProperty Name="Id" ParameterName="EmployeeId" />
	</EndProperty>
</InsertFunction>

But they are of course there in the stored procedure

CREATE PROCEDURE [dbo].[gen_Group_EmployeeInsert]
(
	@EmployeeId [Int] = null,
	@GroupId [Int] = null,
	@created_date [DateTime],
	@created_by [Varchar] (50),
	@modified_by [Varchar] (50)

)
Bug? Or am I doing something wrong here.

Nov 17, 2010 at 12:38 PM

I figured it out, I needed to drop the audit fields from the associative table.

Nov 25, 2010 at 6:15 PM

Yes you are correct about this functionality. It is sort of a bug. Entity Framework does not allow any other fields (other than PK) on an associative table. nHydrate does support this in the NHDAL; however EF does not support this currently. We do not verify this right now since only EF has this issue. We have not come up with a way to verify this with one model and many different generators. We are hoping that Microsoft will fix this error in EF 5 but who knows. At present if you have an associative table you cannot have audit fields on it if you generate EFDAL.