1

I have a exist SQL Server database.

I added to a visual studio 2013 asp.net project a new ado.net entity data model, and gave it the name "DB", with model content 'generate from database'.

the entity framework item was added successfully to the project. The VS auto generated a file and a class for every table, but for the entity name -"DB", it only created a file with comments.

this how the DB.cs file looks :

    //------------------------------------------------------------------------------
    // <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>
    //------------------------------------------------------------------------------

And this for example how the file Person.cs (that represents table Person) looks:

    //------------------------------------------------------------------------------
    // <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; }
        }
    }

1 Answer 1

2

Yes, an empty DB.cs file would be generated. What you need to look for is another file named DB.context.cs. You might find it by expanding DB.edmx and then by expanding DB.Context.tt in the same project where you added the Entity Data Model.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.