Code first filetable in SQL Server

entity-framework entity-framework-6

Question

In my current MVC5 project, I'm attempting to make use of the FileTables capability in SQL Server 2012. Any examples of how to create the file table "table" using code are welcome, thanks. I like to follow the habit of creating all of my tables, indexes, etc. first in code and I'd like to do the same here.

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

Popular Answer

A Code First Migration can include custom SQL.

  • Establish a migrationAdd-Migration
  • Add a Custom SQL statement to enable Filestreams.
  • the database withUpdate-Database

Example of a custom SQL migration:

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