2

I'm new to MVC and am not seeing the difference between Code First and Model First. They seem to be the same thing to me: you write out the classes that will become the domain model and MVC creates the database automatically for you.

I don't see a difference between these two approaches. What am I missing here?

Erik Funkenbusch
  • 90,480
  • 27
  • 178
  • 274
flying227
  • 1,091
  • 3
  • 20
  • 36
  • I saw this post, but the differences still are not clear to me. – flying227 Apr 25 '14 at 15:01
  • Code First: You create the model via code and EF creates the DB for you. Model First: You have a pre-existing database and EF creates the model for you. – Mike C. Apr 25 '14 at 15:05
  • @MikeC. Isn't that last one you mentioned Database First? – flying227 Apr 25 '14 at 15:28
  • You're absolutely right, I misunderstood. This explains it quite well: http://stackoverflow.com/questions/5446316/code-first-vs-model-database-first – Mike C. Apr 25 '14 at 15:36
  • First, MVC has nothing to do with either of them. You're talking about entity framework. Entity Framework is not related to MVC in any way, other than the fact that it's often used in MVC projects. – Erik Funkenbusch Apr 25 '14 at 16:08

1 Answers1

4

There are no differences. Model First or Code First just represent the approaches that programmers can adopt (or database first ).

enter image description here

Andritchi Alexei
  • 1,348
  • 1
  • 14
  • 23
  • 1
    No, the designers of the MVC Framework did not. The Designers of the MVC Framework designed MVC to be database technology agnostic. Entity Framwork, which you are referring to is a totally separate technology not related to MVC in any way, other than it's often used in MVC projects. What's more, you don't need to use a visual designer at all to do Model first. It can be done entirely by hand in XML (and you used to have to do it that way in the early days). – Erik Funkenbusch Apr 25 '14 at 16:10
  • Thanks for correcting me. I edited the answer. – Andritchi Alexei Apr 25 '14 at 16:24