.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Interview Question >> MVC >> Post New Question Subscribe to Interview Questions

What is Code first,Database first and Model First

Posted By :volvo     Posted Date :December 25, 2013    Points :40   Category :MVC 
Code first

.Very popular because hardcore programmers don't like any kind of designers and defining mapping in EDMX xml is too complex.
.Full control over the code (no autogenerated code which is hard to modify).
.General expectation is that you do not bother with DB. DB is just a storage with no logic. EF will handle creation and you don't want to know how it do the job.
.Manual changes to database will be most probably lost because your code defines the database.

Database first

.Very popular if you have DB designed by DBAs, developed separately or if you have existing DB.
.You will let EF create entities for you and after modification of mapping you will generate POCO entities.
.If you want additional features in POCO entities you must either T4 modify template or use partial classes.
.Manual changes to the database are possible because the database defines your domain model. You can always update model from database (this feature works quite good).
.I often use this together VS Database projects (only Premium and Ultimate version).

Model first

.IMHO popular if you are designer fan (= you don't like writing code or SQL).
.You will "draw" your model and let workflow to generate your database script and T4 template to generate yout POCO entities. You will lose part of control on both your entities and database but for small easy projects you will be very productive.
.If you want additional features in POCO entities you must either T4 modify template or use partial classes.
.Manual changes to database will be most probably lost because your model defines the database. This works better if you have Database generation power pack installed. It will allow you updating database schema (instead of recreating) or updating database projects in VS.

You can also find related Interview Question to What is Code first,Database first and Model First  below: 

What is the purpose of the model database?

It works as Template Database for the Create Database Syntax (More...)

What is Code Document Object Model (CodeDom) ?

Code Document Object Model are code generators which are used to minimize repetitive coding tasks, and to minimize the number of human-generated source code lines. (More...)

Database Concurrency in Sql Server.

When two or more user try to update same type of data in a table then Database Concurrency helps in this situation.

There are 2 types of Database Concurrency

Pessimistic: When one user try to change the data with pessimistic concurrency then a lock is placed on the data in a table so that another user cannot change data. when one user finishes then other user can able to change.

Optimistic: When two user works on the same data in a table and one change that data first then second user cannot change that same data becasue the which he have using is allready changed so he cannot do the change becasue change apply to another data that is changed by first user. (More...)

What is the managed and unmanaged code in .net?

The .NET Framework provides a run-time environment called the Common Language Runtime, which manages the execution of code and provides services that make the development process easier. Compilers and tools expose the runtime's functionality and enable you to write code that benefits from this managed execution environment. Code that you develop with a language compiler that targets the runtime is called managed code; it benefits from features such as cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services. (More...)

Can code inside multiple catch block be executed?

No, Code can not execute in mutiple catch block (More...)

What is managed code and managed data?

Managed code is code that is written to target the services of the Common Language Runtime (see What is the Common Language Runtime?). In order to target these services, the code must provide a minimum level of information (metadata) to the runtime. All C#, Visual Basic.NET, and _JScript.NET code is managed by default. Visual Studio.NET C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/CLR).
Closely related to managed code is managed data-data that is allocated and de-allocated by the Common Language Runtime's garbage collector. C#, Visual Basic, and _JScript.NET data is managed by default. C# data can, however, be marked as unmanaged through the use of special keywords. Visual Studio.NET C++ data is unmanaged by default (even when using the /CLR switch), but when using Managed Extensions for C++, a class can be marked as managed by using the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector. In addition, the class becomes a full participating member of the .NET Framework community, with the benefits and restrictions that brings. An example of a benefit is proper interoperability with classes written in other languages (for example, a managed C++ class can inherit from a Visual Basic class). An example of a restriction is that a managed class can only inherit from one base class. (More...)

What are the major data structures used in RDBMS, Network data model & Hierarchical data model.

RDBMS - Array (i.e. Array of structures)
Network data model - Graph
Hierarchical data model - Trees (More...)

What is a Database system?

The database and DBMS software together is called as Database system. (More...)

What is Data Model?

A collection of conceptual tools for describing data, data relationships data semantics and constraints. (More...)

What is E-R model?

This data model is based on real world that consists of basic objects called entities and of relationship among these objects. Entities are described in a database by a set of attributes. (More...)

What is Object Oriented model?

This model is based on collection of objects. An object contains values stored in instance variables with in the object. An object also contains bodies of code that operate on the object. These bodies of code are called methods. Objects that contain same types of values and the same methods are grouped together into classes. (More...)

Difference between imperative and interrogative code.

There are imperative and interrogative functions and I think they are talking about that. Imperative functions are the one which return a
value while the interrogative functions do not return a value. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend