So say I have the following tables in my SQL Server 2012 DB:
Person
PersonId
FirstName
LastName
Photo
PhotoId
PersonId (fk)
DateTaken
PhotoFileTable
(all the FileTable columns)
And the photos stored on disk are structured like this: \\myserver\filestreamshare\People\PersonId\Photo1.tif
And very important: There are a TON of photos ALREADY on disk that need to be added to the database- that's why I thought a FileTable would be cool as it automatically picks them up.
So I need to do 2 things- first, relate the Photo table to the PhotoFileTable so that I can get all photos for a person. And second (and more painful) I want to use Entity Framework 5.0 to do this.
Using the edmx designer, I can't add a table that contains a hierarchyid. Since that is the primary key it seems it should be used as a 1:1 mapping between PhotoId and path_locator (the FileTable hierarchyid). But then I can't add the Photo table either.
What's the best approach here? At the end of the day, I want to have EF objects in C# to use. It ideally would look something like:
class Person
List<Photo>
class Photo
Filestream (to lazy load the image from the filesystem to bitmapimage)
Path (?)
or maybe
class Photo
BitmapImage (lazy load)
Am I going about this the wrong way? Can I get there from here? Thought or suggestions?
Maybe you can try this.
Table:
)
Insert:
Update:
Delete:
And the view:
After this, the images can be read / write with EF as follows: