2016-09-14 5 views
0

Ich habe eine bestehende SQL Server-Datenbank.Entity-Framework - generiert leere Klasse

Ich fügte zu einem Visual Studio 2013 asp.net-Projekt ein neues ado.net-Entity-Datenmodell hinzu und gab ihm den Namen "DB" mit dem Modellinhalt "generate from database".

Das Entitätsrahmenelement wurde dem Projekt erfolgreich hinzugefügt. Der VS automatisch generiert eine Datei und eine Klasse für jede Tabelle, aber für den Entitätsnamen - "DB", erstellt nur eine Datei mit Kommentaren.

dies, wie die DB.cs Datei aussieht:

//------------------------------------------------------------------------------ 
    // <auto-generated> 
    //  This code was generated from a template. 
    // 
    //  Manual changes to this file may cause unexpected behavior in your application. 
    //  Manual changes to this file will be overwritten if the code is regenerated. 
    // </auto-generated> 
    //------------------------------------------------------------------------------ 

Und dies zum Beispiel, wie die Datei Person.cs (das entspricht Tabelle Person) aussieht:

//------------------------------------------------------------------------------ 
    // <auto-generated> 
    //  This code was generated from a template. 
    // 
    //  Manual changes to this file may cause unexpected behavior in your application. 
    //  Manual changes to this file will be overwritten if the code is regenerated. 
    // </auto-generated> 
    //------------------------------------------------------------------------------ 

    namespace Kupa_V1.Dal 
    { 
     using System; 
     using System.Collections.Generic; 

     public partial class Person 
     { 
      public Person() 
      { 
       this.Family = new HashSet<Family>(); 
       this.Family1 = new HashSet<Family>(); 
       this.Help = new HashSet<Help>(); 
      } 

      public int PersonId { get; set; } 
      public Nullable<int> FamilyId { get; set; } 
      public string FirstName { get; set; } 
      public string LastName { get; set; } 
      public System.DateTime DateOfBirth { get; set; } 
      public string TeudatZehut { get; set; } 
      public string Phone { get; set; } 
      public string Email { get; set; } 
      public string Issue { get; set; } 

      public virtual ICollection<Family> Family { get; set; } 
      public virtual ICollection<Family> Family1 { get; set; } 
      public virtual Family Family2 { get; set; } 
      public virtual ICollection<Help> Help { get; set; } 
      public virtual Work Work { get; set; } 
     } 
    } 

Antwort

1

Ja, eine leeres DB.cs Datei würde erzeugt werden. Was Sie suchen müssen, ist eine andere Datei mit dem Namen DB.context.cs. Sie finden es unter Umständen durch Erweitern von DB.edmx und anschließendes Erweitern von DB.Context.tt in demselben Projekt, in dem Sie das Entitätsdatenmodell hinzugefügt haben.

Verwandte Themen