Malatesh Patil
Malatesh Patil

Reputation: 4665

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

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?

Upvotes: 0

Views: 78

Answers (1)

InteXX
InteXX

Reputation: 6367

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.

Upvotes: 1

Related Questions