locked
ADO.NET vs Entity Framework RRS feed

  • Question

  • User-361343671 posted

    What is the differnt between Ado.net and entity framework

    Saturday, December 16, 2017 6:29 AM

Answers

  • User-832373396 posted

    Hi Puspa.,

    What is the differnt between Ado.net and entity framework

    if you choose plain ADO.NET, then you need to <g class="gr_ gr_22 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" id="22" data-gr-id="22">role</g> your own implementations to map to <g class="gr_ gr_23 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="23" data-gr-id="23">db</g> classes. You need to implement them, deal with SQL, test them, maintain them etc. If you wish to change databases, it becomes a new nightmare. EF protects you from the database - it's a standard implementation of an ORM - so you can be sure it's functioning correctly (i.e. you don't need to test your mappings as it's not your code). EF is generalized, meaning that it works across a number of databases. EF <g class="gr_ gr_48 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" id="48" data-gr-id="48">is </g><g class="gr_ gr_24 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="24" data-gr-id="24"><g class="gr_ gr_48 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Grammar multiReplace" id="48" data-gr-id="48">refactor</g> friendly</g>, you can refactor stuff without needing to change magic strings. Yes, it's performance will be lower than raw <g class="gr_ gr_25 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="25" data-gr-id="25">sql</g>, but most of the time the performance you get from it is pretty acceptable. It's a <g class="gr_ gr_26 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="26" data-gr-id="26">peformance</g> vs maintainability + productivity tradeoff.

    If you use entity framework, it could create your model quickly based on your Database, you <g class="gr_ gr_123 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="123" data-gr-id="123">cn</g> simply <g class="gr_ gr_124 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="124" data-gr-id="124">right click</g> anywhere in the <g class="gr_ gr_125 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" id="125" data-gr-id="125">edmx</g> designer and go update model from <g class="gr_ gr_134 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" id="134" data-gr-id="134">database</g>. If the other way round, then you can change the <g class="gr_ gr_126 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="126" data-gr-id="126">db</g> and generate the <g class="gr_ gr_127 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="127" data-gr-id="127">db</g> creation script again. If wiping the <g class="gr_ gr_128 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="128" data-gr-id="128">db</g> is not an option, you'll need to manually change both the <g class="gr_ gr_129 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" id="129" data-gr-id="129">edmx</g> and the <g class="gr_ gr_130 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" id="130" data-gr-id="130">db</g>. But if you were using plain ado.net, you'd still have to change both the <g class="gr_ gr_131 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="131" data-gr-id="131">db</g> and your app code to <g class="gr_ gr_132 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="132" data-gr-id="132">accomodate</g> for any changes.

    References:

    Entity Framework (EF) Documentation

    https://msdn.microsoft.com/en-us/data/ee712907 

    Entity Framework Code-First:

    http://www.entityframeworktutorial.net/code-first/entity-framework-code-first.aspx 

    Hope it is helpful to you.

    With regards, Angelina Jolie

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 18, 2017 9:58 AM