1. Does this work *without* the DNN-EFadapter? I would not be surprised if some bugs existed at that level (it was just released this week and is still technically in beta) -- theEF is a pretty large framework and there are plenty of strange ways to interact with it. Taking the adapter out of the equation would be very helpful in identifying your issue. (Regardless, I would not expect a hard crash caused by the adapter.)
Yes. Running the query ModelContext.Testimonials.First without the ModelAdaptor succeeded. When adding the adaptor, I got the following error when running the same query: 'Index is out of the bounds of the array.' At the same time, I got a hard crash from the internal development web server in Visual Studio 2008 SP1.
2. What is the column schema of your Testimonials table?I'll attempt to reproduce locally.
/****** Object: Table [dbo].[Testimonials] Script Date: 09/04/2009 12:08:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Testimonials]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Testimonials](
[ModuleID] [int] NOT NULL,
[ItemID] [int] IDENTITY(1,1) NOT NULL,
[CreatedByUser] [int] NOT NULL,
[DateCreated] [date] NOT NULL,
[Title] [varchar](200) NOT NULL,
[AuthorName] [varchar](200) NOT NULL,
[AuthorTitle] [varchar](100) NULL,
[AuthorPhoneNumber] [varchar](30) NULL,
[AuthorStreetAddress] [varchar](200) NULL,
[AuthorCity] [varchar](30) NULL,
[AuthorState] [char](2) NULL,
[AuthorZip] [char](5) NULL,
[Comments] [varchar](5000) NOT NULL,
CONSTRAINT [PK_Testimonials] PRIMARY KEY CLUSTERED
(
[ModuleID] ASC,
[Title] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Testimonials]') AND name = N'IX_Testimonials')
CREATE NONCLUSTERED INDEX [IX_Testimonials] ON [dbo].[Testimonials]
(
[ModuleID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Default [DF_Testimonials_DateCreated] Script Date: 09/04/2009 12:08:45 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_Testimonials_DateCreated]') AND parent_object_id = OBJECT_ID(N'[dbo].[Testimonials]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Testimonials_DateCreated]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Testimonials] ADD CONSTRAINT [DF_Testimonials_DateCreated] DEFAULT (getdate()) FOR [DateCreated]
END
End
GO
/****** Object: Check [CK_Testimonials_AuthorZip] Script Date: 09/04/2009 12:08:45 ******/
IF NOT EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_Testimonials_AuthorZip]') AND parent_object_id = OBJECT_ID(N'[dbo].[Testimonials]'))
ALTER TABLE [dbo].[Testimonials] WITH CHECK ADD CONSTRAINT [CK_Testimonials_AuthorZip] CHECK (([AuthorZip] like '[0-9][0-9][0-9][0-9][0-9]'))
GO
IF EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_Testimonials_AuthorZip]') AND parent_object_id = OBJECT_ID(N'[dbo].[Testimonials]'))
ALTER TABLE [dbo].[Testimonials] CHECK CONSTRAINT [CK_Testimonials_AuthorZip]
GO
/****** Object: ForeignKey [FK_Testimonials_Modules] Script Date: 09/04/2009 12:08:45 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Testimonials_Modules]') AND parent_object_id = OBJECT_ID(N'[dbo].[Testimonials]'))
ALTER TABLE [dbo].[Testimonials] WITH NOCHECK ADD CONSTRAINT [FK_Testimonials_Modules] FOREIGN KEY([ModuleID])
REFERENCES [dbo].[Modules] ([ModuleID])
ON DELETE CASCADE
NOT FOR REPLICATION
GO
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Testimonials_Modules]') AND parent_object_id = OBJECT_ID(N'[dbo].[Testimonials]'))
ALTER TABLE [dbo].[Testimonials] CHECK CONSTRAINT [FK_Testimonials_Modules]
GO
3. Does an exception stack exist in your event viewer?
An unhandled exception occurred and the process was terminated.
Application ID: fc04a75c
Process ID: 2116
Exception: System.ArgumentNullException
Message: Value cannot be null.
StackTrace: at System.Threading.Monitor.Enter(Object obj)
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection.Dispose(Boolean disposing)
at System.ComponentModel.Component.Finalize()
Consider opening a work item on the project website with your module files (simplified to the minimum necessary to reproduce the problem, along with SQLto
generate the table and data). If I can reproduce the problem locally, and it IScaused by the DNN-EFadapter, I'll be happy to investigate a remedy.
I will go there and explain it in the same way, unless you want to use this as the bug report instead? Advise...
Had one more thought on this -- does the sample module that I packaged with the adapter release work on your system? That should give some additional evidence
about whether this is an adapter-related issue, or a deeper EF- or system configuration-related problem.
It does not work. As more digging around finds, when the EF model adaptor is installed and currently running in an installed module, any part of the DNN system that requires a login of some kind brings the entire DNN system to its knees and gives a hard crash of the dev server in Visual Studio. Removing the EF adaptor and the module that used it returns DNN to a stable state again. The same issues exist in the linq to sql adaptor except that there is no hard crash of the dev server and the error message is 'Query operator 'ElementAtOrDefault' is not supported'.