Code first filetable in SQL Server

entity-framework entity-framework-6

Question

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.

1
3
10/18/2017 8:07:54 AM

Popular Answer

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!
    } 
}     

1
5/2/2016 12:03:22 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow