3

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.

3 Answers 3

1

Unfortunately I cannot help you with FileTable, but this example of FileStream (similar thing in many ways) works quite well.

Sign up to request clarification or add additional context in comments.

Comments

1

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/

Comments

1

You can add custom SQL in a Code First Migration.

  • Create a migration Add-Migration
  • Put In some Custom SQL to Enable Filestreams
  • Update the db with 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!
    } 
}     

```

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.