We have several ways to access the database with EF : code-first or model-first or database-first design… and I want to know when I use these ways to access the database ?….
Is any standard for these technology for access to the database in my Asp.net web application or asp.net mvc web application?
There are basically two cases – your database exists or your database does not exist. If your database exists you have two options – you can use Entity Designer to reverse engineer your database or use “CodeFirst” for existing database (e.g. by using EF Power Tools reverse engineer). Now if you prefer using classes as a modeling tool rather than lines and boxes (EF Designer) you would pick CodeFirst otherwise you would use the Designer. If you don’t have a database you again have two options – CodeFirst – creating the database based on your classes (CodeFirst) or draw the model with the designer (“line and boxes”) and create the database from what you have drawn. When using CodeFirst (for new databases) you will be able to use migrations which is very useful when you work on a new app and you expect database schema to change/evolve.