SQL Server 2014 Optimized Memory with Entity Framework 6.1 CodeFirst

My application uses two lookup tables that I want to use to optimize memory.

There seems to be no attribute to declare this;

Is it possible to connect to the process of creating a table and find a custom attribute and change the create table command?

I am using Entity Framework 6.1 with First code.

I’m looking for a way to make it declarative, so if, for example, EF 6.2 or a newer version supports it officially, I can refuse my hack.

+4
source share
3 answers

", , , , - , ".

CreateTable sql, , Up Up Sql ( "create table .." ).

Sql Server 2014 . , EF.

+4

, Entity Framework, ?

- (-!):

    public class MyDbInitializer : CreateDatabaseIfNotExists<MyDbContext>
    {
        protected override void Seed(MyDbContext context)
        {
            context.Database.ExecuteSqlCommand("DROP TABLE MyTable");
            context.Database.ExecuteSqlCommand("CREATE TABLE MyTable (bla bla bla)  WITH (MEMORY_OPTIMIZED=ON)");
        }
    }

, SQL 2014, Seed , .

, :

System.Data.Entity.Database.SetInitializer(new MyDbInitializer());
+2

An old question, but FYI memory-optimized tables have first-class support in the upcoming Entity Framework Core 1.1 (a preview has just been released).

+1
source

Source: https://habr.com/ru/post/1536217/


All Articles