Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Table("Address")]
- public class Address
- {
- [Key]
- public long AddressId { get; set; }
- public string Address1 { get; set; }
- public string Address2 { get; set; }
- public string Address3 { get; set; }
- public string Address4 { get; set; }
- public string Address5 { get; set; }
- public string Town { get; set; }
- public string County { get; set; }
- public string Country { get; set; }
- public string PostCode { get; set; }
- public virtual Company Company { get; set; }
- public DateTime? RemovedDate { get; set; }
- public long? RemovedBy { get; set; }
- }
- [Table("Company")]
- public class Company
- {
- [Key ]
- public long CompanyId { get; set; }
- public string Name { get; set; }
- public string WebsiteUrl { get; set; }
- public virtual Address Address { get; set; }
- public User LeadUser { get; set; }
- public DateTime ActiveSince { get; set; }
- public DateTime? ActiveTill { get; set; }
- public string VatRegistration { get; set; }
- public string LicenseKey { get; set; }
- public LicenseStatus LicenseStatus { get; set; }
- public bool CanAgreementBeExtended { get; set; }
- public string BillingEmail { get; set; }
- public string PhoneNumber { get; set; }
- public string MobileNumber { get; set; }
- public DateTime DateCreated { get; set; }
- public DateTime DateUpdated { get; set; }
- public virtual ICollection<User> Users { get; set; }
- public virtual ICollection<LicenseHistory> LicenseHistories { get; set; }
- }
- //Seeded data inserted as follows
- var testCompany = new Company
- {
- ActiveSince = DateTime.UtcNow,
- Name = "Test Company",
- LeadUser = adminUser,
- DateCreated = DateTime.UtcNow,
- DateUpdated = DateTime.UtcNow,
- BillingEmail = "admin@test.co.uk",
- CanAgreementBeExtended = true,
- LicenseStatus = LicenseStatus.PendingAgreement,
- MobileNumber = "1234567890",
- PhoneNumber = "1234567890",
- VatRegistration = "1234567890"
- };
- context.Companies.AddOrUpdate(u => u.Name, testCompany);
- var testAddress = new Address
- {
- Address1 = "Test Ltd",
- Address2 = "1 Test Gardens",
- Address3 = "Test Heath",
- Address4 = string.Empty,
- Address5 = string.Empty,
- County = "Test",
- Town = "Test",
- Country = "United Kingdom",
- PostCode = "TE5 T11",
- Company = testCompany
- };
- context.Addresses.AddOrUpdate(u => new { u.AddressId }, testAddress);
- testCompany.Address = testAddress;
- context.Companies.AddOrUpdate(u => u.Name, testCompany);
- //Fluent API set up as follows in the OnModelCreating
- modelBuilder.Entity<Address>()
- .HasRequired(ad => ad.Company)
- .WithOptional(s => s.Address);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement