NickD NickD - 1 month ago 17
C# Question

SQL Server 2014 Memory Optimized Table with Entity Framework 6.1 CodeFirst

My application uses two lookup tables I want to be Memory Optimized Tables.

There seems to be no Attribute yet to declare this;

Is there a possibility to hook into the table creation process and look for an custom attribute and modify the create table command?

I use Entity Framework 6.1 with Code First.

I seek a way to make it declarative, so if e.g. EF 6.2 or newer version supports it official, i can drop my hack.

Answer

"I suppose it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail."

I'd replace the CreateTable with the specific sql you want to optimise your database, called in the Up migration using Sql("create table etc..").

This is restricted to Sql Server 2014 and further restricted by other requirements for memory optimisation. Not worth the candle trying to do it with attributes within EF.

Comments