Reputation: 463
Trying to take advantage of the FileTables feature in SQL Server 2012 in my current MVC5 project. Does anyone have any examples of how to create the file table "table" using code first? All of my tables, indexes, etc. are done using code first and I'd like to continue that practice here.
Upvotes: 3
Views: 3489
Reputation: 1288
You can add custom SQL in a Code First Migration.
Add-Migration
Update-Database
Example migration with custom SQL:
public partial class AddFileStreamMigration: DbMigration
{
public override void Up()
{
var customSql = @"ALTER DATABASE Photos
SET FILESTREAM (NON_TRANSACTED_ACCESS = FULL)
GO
etc...";
Sql(customSql );
}
public override void Down()
{
//Make sure you put in roll back SQL too!
}
}
```
Upvotes: 1
Reputation: 3355
The decision is available here: "WEB API FILE UPLOAD WITH MS SQL SERVER FILETABLE" https://damienbod.wordpress.com/2014/04/08/web-api-file-upload-with-ms-sql-server-filetable/
Upvotes: 1
Reputation: 184
Unfortunately I cannot help you with FileTable, but this example of FileStream (similar thing in many ways) works quite well.
Upvotes: 1