示例#1
0
        public static void AddCustomer()
        {
            // https://stackoverflow.com/questions/3600175/the-model-backing-the-database-context-has-changed-since-the-database-was-crea
            Database.SetInitializer <RegulatoryDbContext>(null);

            var context = new RegulatoryDbContext();

            Debug.WriteLine(context.Database.Connection.ConnectionString);
            Debug.WriteLine(context.Customers.Count());

            var newCust = new Customer()
            {
                Nome      = "Giovanni",
                Cognome   = "Rossi",
                Matricola = 102488,
                Status    = 1
            };

            context.Customers.Add(newCust);
            context.SaveChanges();
        }
 public void Add(Customer entity)
 {
     _dbContext.Customers.Add(entity);
     _dbContext.SaveChanges();
 }