简体   繁体   English

使用实体框架在数据库中存储对象

[英]Store an object in database using Entity Framework

I plan to save some objects into a database using Entity Framework code first, so I create the classes and generate the database from that. 我计划首先使用Entity Framework代码将一些对象保存到数据库中,因此我创建了类并从中生成数据库。

The files I store are the following: 我存储的文件如下:

  • An HTML file HTML文件
  • and a .mview file. 和一个.mview文件。

These two are exported using Marmoset Viewer. 这两个是使用Marmoset Viewer导出的。 I plan to store them as object type. 我打算将它们存储为object类型。 All I need to do is copy them to folders (and add a new one to the database). 我需要做的就是将它们复制到文件夹(然后向数据库中添加一个新文件夹)。

My question is: is this way, going with an object type doable? 我的问题是:这样,使用object类型可行吗? Or do I have to change something? 还是我必须改变一些东西?

The HTML file will be opened using a WebBrowser control. HTML文件将使用WebBrowser控件打开。 It works, but so far I haven't made the database just yet. 它可以工作,但是到目前为止我还没有建立数据库。

Your entities, use byte[] for storing binary files. 您的实体,使用byte[]来存储二进制文件。 Your matching table column types should be varbinary . 您的匹配表列类型应为varbinary

You can use System.IO.File.ReadAllBytes to load your entity's property. 您可以使用System.IO.File.ReadAllBytes加载实体的属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何首先使用 Entity Framework 6 代码将 object 作为字符串存储在数据库中 - How to store an object as a string in database using Entity Framework 6 code first 使用Entity Framework Core将文件存储在数据库中 - Store files in database using Entity Framework Core 列中的实体框架存储对象 - Entity Framework Store Object in Column 如何使用实体框架将 RichTextBox 内容存储到 WPF 中的 SQLServer 数据库 - How to Store RichTextBox Content to SQLServer Database in WPF using Entity Framework 使用实体框架6将数据从数据库存储到本地 - Store data from database to local using entity framework 6 使用实体框架在SQL Server中存储对象列表 - Store list of object in SQL Server using Entity Framework 使用Entity Framework使用子集合更新对象,从而导致数据库重复 - Updating object with child collection using Entity Framework causing duplicates in database 使用实体框架复制对象数据并更新数据库 - Copying object data and updating the database using entity framework 在数据库表上使用代码优先实体框架的无效对象名称 - Invalid object name using code first Entity Framework on database table 使用Entity Framework 6在数据库中查找等效的嵌套对象 - Find equivalent nested object inside database using Entity Framework 6
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM