[Solved] How to use a class created by the entity framework [closed]


I resume step by step:

1 – Create a console project.

2 – Install EF using Nuget: Install-Package EntityFramework

3 – Create SalesRepresentative:

namespace EF {
    public partial class SalesRepresentative {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
        public string CellPhone { get; set; }
    }
}

4 – Create GeneralContext

namespace EF {
    public class GeneralContext: DbContext {

        public DbSet<SalesRepresentative> SalesRepresentatives { get; set; }
    }
}

5 – So:

namespace EF {
    class Program {
        static void Main(string[] args) {

            using (var ctx = new GeneralContext()) {
                SalesRepresentative emp = new SalesRepresentative() { Name = "Prashant" };
                ctx.SalesRepresentatives.Add(emp);
                ctx.SaveChanges();
            }
        }
    }
}

Note: In the App.config file (or web.config) you should customize the connection string.

1

solved How to use a class created by the entity framework [closed]