Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am using Entity Framework 5 to work with this database but I am getting issues with how tblTalkers and tblChatSessions are being mapped in the entity model when imported into Visual Studio. Please let me know if you need more info.

my database diagram

(fullsize image available here)

Here's my DDL for the whole database with the tables as well

USE [master]
GO

/******
    Object:  Database [QuickChatApplication]
    Script Date: 11/17/2012 10:02:15 AM 
******/
CREATE DATABASE [QuickChatApplication]
CONTAINMENT = NONE
ON  PRIMARY 
( 
    NAME = N'QuickChatApplication'
    , FILENAME = N'C:\Program Files\Mi...SQL\DATA\QuickChatApplication.mdf'
    , SIZE = 5120KB 
    , MAXSIZE = UNLIMITED
    , FILEGROWTH = 1024KB
)
LOG ON 
( 
    NAME = N'QuickChatApplication_log'
    , FILENAME = N'C:\Program Files\Mi...SQL\DATA\QuickChatApplication_log.ldf' 
    , SIZE = 2048KB 
    , MAXSIZE = 2048GB 
    , FILEGROWTH = 10%
)
GO

ALTER DATABASE [QuickChatApplication] SET COMPATIBILITY_LEVEL = 110
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
    EXEC [QuickChatApplication].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [QuickChatApplication] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [QuickChatApplication] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [QuickChatApplication] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [QuickChatApplication] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [QuickChatApplication] SET ARITHABORT OFF 
GO

ALTER DATABASE [QuickChatApplication] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [QuickChatApplication] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [QuickChatApplication] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [QuickChatApplication] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [QuickChatApplication] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [QuickChatApplication] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [QuickChatApplication] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [QuickChatApplication] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [QuickChatApplication] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [QuickChatApplication] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [QuickChatApplication] SET  DISABLE_BROKER 
GO

ALTER DATABASE [QuickChatApplication] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [QuickChatApplication] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [QuickChatApplication] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [QuickChatApplication] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [QuickChatApplication] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [QuickChatApplication] SET READ_COMMITTED_SNAPSHOT OFF 
GO

ALTER DATABASE [QuickChatApplication] SET HONOR_BROKER_PRIORITY OFF 
GO

ALTER DATABASE [QuickChatApplication] SET RECOVERY FULL 
GO

ALTER DATABASE [QuickChatApplication] SET  MULTI_USER 
GO

ALTER DATABASE [QuickChatApplication] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [QuickChatApplication] SET DB_CHAINING OFF 
GO

ALTER DATABASE [QuickChatApplication] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO

ALTER DATABASE [QuickChatApplication] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO

ALTER DATABASE [QuickChatApplication] SET  READ_WRITE 
GO



USE [QuickChatApplication]
GO

/****** 
    Object:  Table [dbo].[tblChatRooms]
    Script Date: 11/17/2012 10:07:21 AM 
******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tblChatRooms]
(
    [RoomId] [int] NOT NULL,
    [CreatorsId] [int] NOT NULL,
    [CreatedTime] [datetime] NOT NULL,
    CONSTRAINT [PK_ChatRooms] PRIMARY KEY CLUSTERED 
    (
        [RoomId] ASC
    ) WITH (
        PAD_INDEX = OFF
        , STATISTICS_NORECOMPUTE = OFF
        , IGNORE_DUP_KEY = OFF
        , ALLOW_ROW_LOCKS = ON
        , ALLOW_PAGE_LOCKS = ON
        ) ON [PRIMARY]
) ON [PRIMARY]

GO




USE [QuickChatApplication]
GO

/****** 
    Object:  Table [dbo].[tblTalkers]
    Script Date: 11/17/2012 10:10:39 AM 
******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tblTalkers]
(
    [TalkerId] [int] NOT NULL,
    [FirstName] [nvarchar](15) NULL,
    [LastName] [nvarchar](15) NULL,
    [ChatAlias] [nvarchar](15) NOT NULL,
    [EmailAddress] [nvarchar](25) NULL,
    [CurrentRoomId] [int] NULL,
    CONSTRAINT [PK_Talkers] PRIMARY KEY CLUSTERED 
    (
        [TalkerId] ASC
    ) WITH (
        PAD_INDEX = OFF
        , STATISTICS_NORECOMPUTE = OFF
        , IGNORE_DUP_KEY = OFF
        , ALLOW_ROW_LOCKS = ON
        , ALLOW_PAGE_LOCKS = ON
    ) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[tblTalkers]  WITH CHECK 
ADD CONSTRAINT [FK_tblTalkers_tblChatRooms] 
FOREIGN KEY([CurrentRoomId])
REFERENCES [dbo].[tblChatRooms] ([RoomId])
GO

ALTER TABLE [dbo].[tblTalkers] 
CHECK CONSTRAINT [FK_tblTalkers_tblChatRooms]
GO




USE [QuickChatApplication]
GO

/****** 
    Object:  Table [dbo].[tblChatSessions]
    Script Date: 11/17/2012 10:07:35 AM 
******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tblChatSessions]
(
    [SessionId] [int] NOT NULL,
    [StartTime] [datetime] NOT NULL,
    CONSTRAINT [PK_ChatSessions] PRIMARY KEY CLUSTERED 
    (
        [SessionId] ASC
    )WITH (
        PAD_INDEX = OFF
        , STATISTICS_NORECOMPUTE = OFF
        , IGNORE_DUP_KEY = OFF
        , ALLOW_ROW_LOCKS = ON
        , ALLOW_PAGE_LOCKS = ON
    ) ON [PRIMARY]
) ON [PRIMARY]

GO



USE [QuickChatApplication]
GO

/******
    Object:  Table [dbo].[tblChatSessionStarters]
    Script Date: 11/17/2012 10:10:20 AM
******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tblChatSessionStarters]
(
    [ChatSessionId] [int] NOT NULL,
    [StartersId] [int] NOT NULL
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[tblChatSessionStarters]  WITH CHECK 
ADD CONSTRAINT [FK_tblChatSessionStarters_tblChatSessions] 
FOREIGN KEY([ChatSessionId])
REFERENCES [dbo].[tblChatSessions] ([SessionId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[tblChatSessionStarters] 
CHECK CONSTRAINT [FK_tblChatSessionStarters_tblChatSessions]
GO

ALTER TABLE [dbo].[tblChatSessionStarters]  WITH CHECK 
ADD CONSTRAINT [FK_tblChatSessionStarters_tblTalkers] 
FOREIGN KEY([StartersId])
REFERENCES [dbo].[tblTalkers] ([TalkerId])
GO

ALTER TABLE [dbo].[tblChatSessionStarters] 
CHECK CONSTRAINT [FK_tblChatSessionStarters_tblTalkers]
GO



USE [QuickChatApplication]
GO

/****** 
    Object:  Table [dbo].[tblSessionsTalkers]
    Script Date: 11/17/2012 10:10:33 AM 
******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tblSessionsTalkers]
(
    [SessionId] [int] NOT NULL,
    [TalkerId] [int] NOT NULL
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[tblSessionsTalkers]  WITH CHECK 
ADD CONSTRAINT [FK_tblSessionsTalkers_tblChatSessions] 
FOREIGN KEY([SessionId])
REFERENCES [dbo].[tblChatSessions] ([SessionId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[tblSessionsTalkers] 
CHECK CONSTRAINT [FK_tblSessionsTalkers_tblChatSessions]
GO

ALTER TABLE [dbo].[tblSessionsTalkers]  WITH CHECK 
ADD CONSTRAINT [FK_tblSessionsTalkers_tblTalkers] 
FOREIGN KEY([TalkerId])
REFERENCES [dbo].[tblTalkers] ([TalkerId])
ON UPDATE CASCADE
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[tblSessionsTalkers] 
CHECK CONSTRAINT [FK_tblSessionsTalkers_tblTalkers]
GO




USE [QuickChatApplication]
GO

/****** 
    Object:  Table [dbo].[tblMessages]
    Script Date: 11/17/2012 10:10:27 AM 
******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tblMessages]
(
    [MessageId] [int] NOT NULL,
    [MessageText] [nvarchar](500) NOT NULL,
    [SendersId] [int] NOT NULL,
    [SessionId] [int] NOT NULL,
    [SentTime] [datetime] NOT NULL,
    CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED 
    (
        [MessageId] ASC
    ) WITH (
        PAD_INDEX = OFF
        , STATISTICS_NORECOMPUTE = OFF
        , IGNORE_DUP_KEY = OFF
        , ALLOW_ROW_LOCKS = ON
        , ALLOW_PAGE_LOCKS = ON
    ) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[tblMessages]  WITH CHECK 
ADD CONSTRAINT [FK_tblMessages_tblChatSessions] 
FOREIGN KEY([SessionId])
REFERENCES [dbo].[tblChatSessions] ([SessionId])
GO

ALTER TABLE [dbo].[tblMessages] 
CHECK CONSTRAINT [FK_tblMessages_tblChatSessions]
GO

ALTER TABLE [dbo].[tblMessages]  WITH CHECK 
ADD CONSTRAINT [FK_tblMessages_tblTalkers] 
FOREIGN KEY([SendersId])
REFERENCES [dbo].[tblTalkers] ([TalkerId])
GO

ALTER TABLE [dbo].[tblMessages] 
CHECK CONSTRAINT [FK_tblMessages_tblTalkers]
GO
share|improve this question
    
You'll need to improve the image, it is unreadable with the scaling that Stack Overflow applies. –  Richard Nov 17 '12 at 9:52
3  
Question: why do you call it "tblChatRooms" when you already know it's a table? –  John Saunders Nov 17 '12 at 9:54
3  
You also might try posting the DDL so we don't have to guess to reproduce your issue. Which, BTW, you didn't tell us your issue. –  John Saunders Nov 17 '12 at 9:54
2  
Again: what's the issue. And: it's hard to improve a data model without knowing the business rules. Can chatters only enlist in one chat room, for instance? Is there no history of chat rooms they visited? Is a session over when the starter quits? Why does a starter have a specific role anyway? Is a session not related to a room? Etc. etc. –  Gert Arnold Nov 17 '12 at 10:34
1  
If you post code, XML or data samples, PLEASE highlight those lines in the text editor and click on the "code samples" button ( { } ) on the editor toolbar to nicely format and syntax highlight it! –  marc_s Nov 17 '12 at 11:04
show 8 more comments

migrated from stackoverflow.com Nov 17 '12 at 11:23

This question came from our site for professional and enthusiast programmers.

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.