如何使用实体框架代码首先存储图像CTP 5? [英] How to store images using Entity Framework Code First CTP 5?

查看:108
本文介绍了如何使用实体框架代码首先存储图像CTP 5?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想弄清楚是否有一种简单的方式来存储和检索二进制(文件)数据使用EF Code First CTP 5?我真的很喜欢使用FILESTREAM类型,但我真的只是寻找一些方法来使其工作。

解决方案

您不能在EF中使用SQL FILESTREAM 。 EF应该在不同的数据库服务器之上工作,但是filestream功能是SQL 2008和更高版本的特定功能。您可以尝试旧的方式 - 在数据库表中使用 varbinary(max),并在映射类中使用字节数组。



编辑:



一点澄清 - 您可以使用 FILESTREAM 数据库,但EF不会利用流。它将作为标准 varbinary(max)加载。


I'm just trying to figure out if there is a simple way to store and retrieve binary (file) data using EF Code First CTP 5? I would really like it to use the FILESTREAM type, but I'm really just looking for some way to make it work.

解决方案

You can't use SQL FILESTREAM in EF. EF is supposed to work on top of different database servers but filestream feature is specific feature of SQL 2008 and newer. You can try to do it old way - use varbinary(max) in your database table and use byte array in your mapped class.

Edit:

Little clarification - you can use FILESTREAM in the database but EF will not take advantage of streaming. It will load it as standard varbinary(max).

这篇关于如何使用实体框架代码首先存储图像CTP 5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆