I am trying to use entity framework in a DNN 5.1 module. For some wierd reason, I keep getting the error 'Index is outside the bounds of the array.' and then the built in development server crashes with an unhandled exception was thrown error in the Dr. Watson debugger window. What could possibly be the problem?
The exact SQL statement I am trying to convert to entity query model is:
select top(1) * from Testimonials where ModuleId=@ModuleID order by NewID()
This is the Query builder methods I used to create the same thing:
using DB as new TestimonialsModelContainer()
formView1.DataSource = DB.Where(It.ModuleID = @ModuleID", New ObjectParameter("ModuleID", ModuleID)).OrderBy("NewID()").Top(1)
formView1.DataBind()
End using
I went through the standard EDML wizard, chose the SiteSqlServer connectionString from the web.config, choose the Testimonials table from the list and let the wizard create the model. I then told the wizard the Context namespace was EternityRecords.Modules.Testimonials and let it finish. I then used the Entity framework adaptor for DNN to allow for objectQualifier and databaseOwner changes. Any clue why this would fail? I used some sample queries from the entity framework part of msdn to the T, except adapting them to fit the model I use. Still fails. Hopefully we can get this running.