17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4: <strong>FILESTREAM</strong> with Entity Framework and LINQ to <strong>SQL</strong>CREATE DATABASE NorthPole ONPRIMARY (NAME = NorthPoleDB,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter4\NorthPoleDB.mdf'), FILEGROUP NorthPole_fs CONTAINS <strong>FILESTREAM</strong>(NAME = NorthPole_fs,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter4\NorthPole_fs')LOG ON (NAME = NorthPole_log,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter4\NorthPole_log.ldf')GOListing 4-1:Rebuilding the sample NorthPole database.Next, create a table to store the <strong>FILESTREAM</strong> data using the code in Listing 4-2.USE NorthPoleGOCREATE TABLE [dbo].[Items]([ItemID] INT IDENTITY PRIMARY KEY,[ItemGuid] UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL UNIQUE,[ItemNumber] VARCHAR(20),[ItemDescription] VARCHAR(50),[ItemImage] VARBINARY(MAX) <strong>FILESTREAM</strong> NULL)GOListing 4-2:Creating a table for the <strong>FILESTREAM</strong> data.Lab 2a: A simple EF application using T-<strong>SQL</strong> accessIn this lab we'll create a simple application that will treat the <strong>FILESTREAM</strong> column asa plain VARBINARY(MAX) column. This is the default way Entity Framework handles<strong>FILESTREAM</strong> data. For applications that seek to leverage the streaming benefits <strong>of</strong><strong>FILESTREAM</strong>, this isn't a suitable approach, so you may want to review the alternativeapproach in Lab 2b.134

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!