locked
Why i am getting so many issues using MVC5 code first linq with entity framework RRS feed

  • Question

  • User-471420332 posted

    I have one big doubt on MVC technology, In my previous project i have worked using  MVC5 , linq and entity framework using code first approach. I got so many escalation from clients because escalation reasons are below

    1) Database migration if i have any change in validation field to non mandatory in razor view then i have to stop the website for Executing migration script.

    2) First time linq take loading time more.

    3) higher risk of data losing.

    Please suggest for the technology because my all experience is in C# asp.net web forms

    Thursday, November 22, 2018 5:57 PM

All replies

  • User1120430333 posted

    1) Database migration if i have any change in validation field to non mandatory in razor view then i have to stop the website for Executing migration script

    Myself, I don't consider any ORM like EF to be a database administration tool. You might be better off using EF Database first and T-SQL database migration scripts. 

    2) First time linq take loading time more.

    It's called cold vs warm queries.

    https://docs.microsoft.com/en-us/ef/ef6/fundamentals/performance/perf-whitepaper

    3) higher risk of data losing.

    What? Are you talking about migrations?

    Please suggest for the technology because my all experience is in C# asp.net web forms

    EF code first is OK as long as you don't use EF as a database administration tool, IMO.

    Your other options are the following:

    1) use ADO.NET, SQL Command objects parametrized inline T-SQL or  parametrized  sprocs, a data reader, and the  DTO pattern for CRUD with the database.

    https://www.codeproject.com/Articles/1050468/Data-Transfer-Object-Design-Pattern-in-Csharp

    2) use Dapper a micro orm.

    https://exceptionnotfound.net/dapper-vs-entity-framework-vs-ado-net-performance-benchmarking/

    Thursday, November 22, 2018 6:28 PM
  • User-271186128 posted

    Hi mazhar,

    Database migration if i have any change in validation field to non mandatory in razor view then i have to stop the website for Executing migration script.

    Check the fields, whether it needs to migrate and change the database. Perhaps, you could try to use View Model in the Razor view, and validate the View Model, then, store the validated values in the database.

    2) First time linq take loading time more.

    As DA924 said, it's called cold vs warm queries.

    3) higher risk of data losing.

    You could automatically set up SQL Server backups on a schedule.

    If you are using SQL Server Express, you can't use SQL Agent, so you must do it using a script (.bat or another) and schedule it with Windows Schedule task (or another program).

    If you have another version, you can create a Maintenance plan for a full backup and then with SQL Agent create a Job to run it.

    You could refer to this answer for more details.

    Best regards,
    Dillion

    Friday, November 23, 2018 2:15 AM