title: WCF with Entity Framework Code First
body: <p>I want to use EF behind my WCF service to fetch data and display it to the client. I need the following suggestions:</p>
  
  <ol>
  <li><p>Do I need to have the same interface for all the views (e.g. students, teachers etc.) or do I need to have a different interface and service for every table (or view)</p></li>
  <li><p>Do I need to generate the database calls within my service (<code>.svc</code>) or some other architecture is preferred?</p>
  
  <pre><code>public Student[] GetAllStudents()
  {
     //database generation code here
  }
  </code></pre></li>
  <li><p>How can I use EF code-first approach to generate database. I know that for an MVC app, you need to set the initializer in <code>Global.asax</code> or in <code>web.config</code> but I am not sure how it's called in this case. My model looks like this:</p>
  
  <pre><code>[DataContract]
  public class Student
  {
      [DataMember]
      [Key]
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int Id { get; set; }
      [DataMember]
      public string Type { get; set; }
      [DataMember]
      public string Subject { get; set; }
      [DataMember]
      public string Description { get; set; }
  }
  </code></pre></li>
  </ol>