Entity framework Core - Ambiguity over choosing Code First Approach and Database First Approach

ef-code-first ef-database-first entity-framework-core

Question

Choosing the Code First approach or the Database First approach with Entity Framework Core for my case is looking confusing from best approach point of view.

I have an existing database with some complex stored procedures.

  1. If I choose the Database First approach, will it be good from performance point of view?

  2. If I choose the Code First approach, can I map the existing Stored Procedures with Entities using Entity Framework Core? If this is possible, are there any disadvantages?

1
0
1/16/2019 6:41:40 PM

Popular Answer

We can't map them yet, but we can call them:

Public Class Sample
  Private Sub SpTest()
    Dim oContext As SchoolContext
    Dim oStudents As List(Of Student)

    oContext = New SchoolContext
    oStudents = oContext.Students.FromSql("GetStudents 'Bill'").ToList
  End Sub
End Class

There are some limitations:

  • The Stored Procedure must return Entity data
  • Magic String usage (although this can be averted by building a small API)
  • Named parameters are not supported yet in EF Core (as of the writing of the article below)

You can find more info here:

http://www.entityframeworktutorial.net/efcore/working-with-stored-procedure-in-ef-core.aspx

As to your performance question, I'd suggest doing some testing and benchmarking.

1
1/16/2019 6:38:38 PM


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