none
Entity Framework with Stored Procedures or just default. RRS feed

  • General discussion

  • I've been using Entity Framework lately in few of my projects.

    I know EF makes life much easier, since it implements CRUD functions for you automatically.

    However, my question is... is there a need to manually implement CRUD using Stored Procedure and assign those procedures to EF ?

    or should I just leave it as it is...

    Also , i want to know by default, EF will need access to data table read/write permissions. Do you guys just create a new login with those permissions on the database?

    Previously, we have users which only have access to the stored procedures..how is this implemented in EF?

    Tuesday, January 15, 2013 11:01 PM

All replies

  • Hi alphabeatsco;

    To your question, "is there a need to manually implement CRUD using Stored Procedure and assign those procedures to EF ? or should I just leave it as it is...", that really all depends on your site. Some companies requirer that all queries be through a stored procedure and others do not. Stored procedures can be useful when trying to do something that has no EF implementation. 

    To your statement, "Also , i want to know by default, EF will need access to data table read/write permissions. Do you guys just create a new login with those permissions on the database?", well EF is not the object that needs access to tables that is done per user / group and is sent to SQL server via the connection string.

    To your question, "Previously, we have users which only have access to the stored procedures..how is this implemented in EF?", please see this web post and video on Stored Procedures in the Entity Framework.

        

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Wednesday, January 16, 2013 5:29 AM
  • To me, I have no problems with EF's CRUD, I see no extra benefits for Stored Procedures, unless it can be reused or performance gain.

    However, they are always people in the company, that feels uncomfortable with EF's CRUD operations.

    Just say, if I decided to go without Stored Procedure...EF will require access to the databases's table directly rather than stored procedure.

    Can I just simply create a new login in SQL Server that has access to that database, with read and write permissions...eg db_datareader and db_datawriter.

    Is this the common practice? Do Microsoft promote using stored procedures instead?

    PS. I know there are millions of ways to skin a cat. However, I'm after the Best Practice by Microsoft.

    Wednesday, January 16, 2013 5:43 AM
  • Hi alphabeatsco;

    To your statement, "Just say, if I decided to go without Stored Procedure...EF will require access to the databases's table directly rather than stored procedure.", as I stated in my previous post EF does NOT have direct access to database or its tables. Database security, login is handled by the database with the credentials passed to it via the connection string. Commands are sent as text which the SQL server will run.

    To your question, "Can I just simply create a new login in SQL Server that has access to that database, with read and write permissions...eg db_datareader and db_datawriter.", yes and those credentials are passed to SQL server via the connection string.

    To your question, "s this the common practice? Do Microsoft promote using stored procedures instead?", I have NOT read anything from Mircrosoft stating that one way is better then the other in this matter.  

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Wednesday, January 16, 2013 2:48 PM