First code script in SQL Server

Trying to use FileTables feature in SQL Server 2012 in my current MVC5 project. Does anyone have examples on how to create a file table "table" using the code in the first place? All my tables, indexes, etc. Are performed using code first, and I would like to continue this practice here.

+3


source to share


3 answers


Unfortunately I can't help you with the FileTable, but this FileStream example (seems to be different) works well enough.



+1


source


The solution is available here: "WEB API FILE DOWNLOADS FROM MS SQL SERVER FILETABLE" https://damienbod.wordpress.com/2014/04/08/web-api-file-upload-with-ms-sql-server-filetable/



+1


source


You can add native SQL in your first code migration.

  • Create transfer Add-Migration

  • Paste some custom SQL to include Filestreams
  • Update db with Update-Database

Migration example using 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


source







All Articles