static void Main(string[] args) { GringottsContext gringotts = new GringottsContext(); gringotts.Database.Initialize(true); try { WizardDeposits deposit = new WizardDeposits { FirstName = "Albus", LastName = "Dumbledore", Age = 150, MagicWandCreator = "Antioch Paverell", MagicWandSize = 15, DepositStartDate = new DateTime(2016, 10, 20), DepositExpirationDate = new DateTime(2020, 10, 20), DepositAmount = 20000.24m, DepositCharge = 0.2m, IsDepositGroup = false }; gringotts.Deposits.Add(deposit); gringotts.SaveChanges(); } catch (DbEntityValidationException ex) { foreach (DbEntityValidationResult dbEntityValidationResult in ex.EntityValidationErrors) { foreach (DbValidationError dbValidationError in dbEntityValidationResult.ValidationErrors) { Console.WriteLine(dbValidationError.ErrorMessage); } } } }
static void Main(string[] args) { WizardDeposit dumbledore = new WizardDeposit() { FirstName = "Albus", LastName = "Dumbledore", Age = 150, MagicWandCreator = "Antioch Peverell", MagicWandSize = 15, DepositStartDate = new DateTime(2016, 10, 20), DepositExpirationDate = new DateTime(2020, 10, 20), DepositAmount = 20000.24m, DepositCharge = 0.2m, IsDepositExpired = false }; var context = new GringottsContext(); context.WizardDeposits.Add(dumbledore); context.SaveChanges(); }
static void Main() { GringottsContext context = new GringottsContext(); WizardDeposits deposit = new WizardDeposits { FirstName = "Stoyan", LastName = "Ivanov", Age = 37, MagicWandCreator = "magic creator", MagicWandSize = 15, DepositStartDate = new DateTime(2016, 10, 20), DepositExpirationDate = new DateTime(2020, 10, 20), DepositAmount = 20000.24m, DepositCharge = 0.2, IsDepositeExpired = false }; User user = new User { Username = "******", Password = "******", Email = "*****@*****.**", Age = 37, IsDeleted = false, RegisteredOn = DateTime.Now }; Album album = new Album() { Name = "FirstAlbum", }; user.Albums.Add(album); //context.WizardDepositses.Add(deposit); context.Users.Add(user); context.SaveChanges(); }