我們先以一個簡單的新聞訊息功能為範例
A.資料表:NewsCategory 新聞類別
CREATE TABLE [dbo].[NewsCategory](
[id] [int] IDENTITY(1,1) NOT NULL,
[Category] nvarchar NULL,
[IsEnabled] [bit] NULL,
CONSTRAINT [PK_NewsCategory] PRIMARY KEY CLUSTERED
(
[id] 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
CREATE TABLE [dbo].[News](
[id] [int] IDENTITY(1,1) NOT NULL,
[title] nvarchar NULL,
[Content] nvarchar NULL,
[Cid] [int] NULL,
[CreateDate] [datetime] NULL,
CONSTRAINT [PK_News] PRIMARY KEY CLUSTERED
(
[id] 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].[News] ADD CONSTRAINT [DF_News_CreateDate] DEFAULT (getdate()) FOR [CreateDate]
GO
### 建立一個asp.net web MVC
建立一個 asp.net web 應用程式
這邊專案名稱為 MVC30dayAdoNet