-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GetDefaultDatabaseName throws ArgumentNullException for table splitting #23672
Comments
Unless you share some code and tell use which EF Core provider and version you use, it will be quite hard to help you. |
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
namespace ResourcePlanner
{
public class ResourcesContext : DbContext
{
public ResourcesContext(DbContextOptions options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Person>()
.HasMany(p => p.Organizations)
.WithMany(o => o.Persons)
.UsingEntity<OrganizationPerson>(
j => j.HasOne(m => m.Organization).WithMany(o => o.OrganizationPersons),
j => j.HasOne(m => m.Person).WithMany(o => o.OrganizationPersons));
}
#nullable disable
public DbSet<Person> Persons { get; set; }
public DbSet<Organization> Organizations { get; set; }
public DbSet<OrganizationPerson> OrganizationPersons { get; set; }
public DbSet<PersonType> PersonTypes { get; set; }
public DbSet<Equipment> Equipment { get; set; }
public DbSet<EquipmentType> EquipmentTypes { get; set; }
public DbSet<Address> Addresses { get; set; }
public DbSet<AddressType> AddressTypes { get; set; }
public DbSet<PhoneNumber> PhoneNumbers { get; set; }
public DbSet<EmailAddress> EmailAddresses { get; set; }
public DbSet<Product> Products { get; set; }
public DbSet<ProductType> ProductTypes { get; set; }
public DbSet<ProductCategory> ProductCategories { get; set; }
public DbSet<ProductAttribute> ProductAttributes { get; set; }
public DbSet<ProductBulkPrice> ProductBulkPrices { get; set; }
public DbSet<ProductResource> ProductResources { get; set; }
public DbSet<Discount> Discounts { get; set; }
public DbSet<OrderUnit> OrderUnits { get; set; }
public DbSet<Object> Objects { get; set; }
public DbSet<Property> Properties { get; set; }
public DbSet<PropertyType> PropertyTypes { get; set; }
public DbSet<Order> Orders { get; set; }
public DbSet<OrderType> OrderTypes { get; set; }
public DbSet<OrderStatus> OrderStatuses { get; set; }
public DbSet<OrderItem> OrderItems { get; set; }
public DbSet<Delivery> Deliveries { get; set; }
public DbSet<DeliveryStatus> DeliveryStatuses { get; set; }
public DbSet<DeliveryItem> DeliveryItems { get; set; }
public DbSet<Invoice> Invoices { get; set; }
public DbSet<InvoiceType> InvoiceTypes { get; set; }
public DbSet<InvoiceStatus> InvoiceStatuses { get; set; }
public DbSet<InvoiceItem> InvoiceItems { get; set; }
public DbSet<Resource> Resources { get; set; }
public DbSet<ResourceType> ResourceTypes { get; set; }
public DbSet<ResourceGroup> ResourceGroups { get; set; }
public DbSet<ResourceGroupMember> ResourceGroupMembers { get; set; }
public DbSet<ResourceAllocation> ResourceAllocations { get; set; }
#nullable restore
}
public interface IEntity
{
int Id { get; set; }
DateTime CreationDate { get; set; }
DateTime? UpdateDate { get; set; }
bool? IsDeleted { get; set; }
DateTime? DeletionDate { get; set; }
}
public class Person : IEntity
{
public Person()
{
Organizations = new HashSet<Organization>();
OrganizationPersons = new HashSet<OrganizationPerson>();
Addresses = new HashSet<Address>();
EmailAddresses = new HashSet<EmailAddress>();
PhoneNumbers = new HashSet<PhoneNumber>();
Objects = new HashSet<Object>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string FirstName { get; set; } = null!;
public string? MiddleName { get; set; }
public string GivenName { get; set; } = null!;
public string? Nickname { get; set; }
public string LastName { get; set; } = null!;
public string Ssn { get; set; } = null!;
public DateTime? BirthDate { get; set; } = null!;
public bool? IsDeceased { get; set; } = null!;
public DateTime? DeathDate { get; set; } = null!;
public ICollection<Organization> Organizations { get; set; }
public ICollection<OrganizationPerson> OrganizationPersons { get; set; }
public ICollection<Address> Addresses { get; set; }
public ICollection<EmailAddress> EmailAddresses { get; set; }
public ICollection<PhoneNumber> PhoneNumbers { get; set; }
public ICollection<Object> Objects { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Organization : IEntity
{
public Organization()
{
Persons = new HashSet<Person>();
OrganizationPersons = new HashSet<OrganizationPerson>();
Addresses = new HashSet<Address>();
EmailAddresses = new HashSet<EmailAddress>();
PhoneNumbers = new HashSet<PhoneNumber>();
Objects = new HashSet<Object>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string OrgNo { get; set; } = null!;
public string VatNo { get; set; } = null!;
public ICollection<Person> Persons { get; set; }
public ICollection<OrganizationPerson> OrganizationPersons { get; set; }
public ICollection<Address> Addresses { get; set; }
public ICollection<EmailAddress> EmailAddresses { get; set; }
public ICollection<PhoneNumber> PhoneNumbers { get; set; }
public ICollection<Object> Objects { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class OrganizationPerson : IEntity
{
public int Id { get; set; }
public Organization Organization { get; set; } = null!;
public int OrganizationId { get; set; }
public Person Person { get; set; } = null!;
public int PersonId { get; set; }
public PersonType PersonType { get; set; } = null!;
public int PersonTypeId { get; set; }
public string? Title { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public interface IHasChildren<T>
{
public T? Parent { get; set; }
public ICollection<T> ChildItems { get; set; }
}
public class PersonType : IEntity, IHasChildren<PersonType>
{
public PersonType()
{
ChildItems = new HashSet<PersonType>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public PersonType? Parent { get; set; }
public int? ParentId { get; set; }
public ICollection<PersonType> ChildItems { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Address : IEntity, IAddressDetails
{
public int Id { get; set; }
public Organization Organization { get; set; } = null!;
public int OrganizationId { get; set; }
public Person Person { get; set; } = null!;
public int PersonId { get; set; }
public AddressType AddressType { get; set; } = null!;
public int AddressTypeId { get; set; }
public string? CareOf { get; set; }
public string Street { get; set; } = null!;
public string StreetNo { get; set; } = null!;
public string ZipCode { get; set; } = null!;
public string? Box { get; set; }
public string City { get; set; } = null!;
public string Region { get; set; } = null!;
public string Country { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public interface IAddressDetails
{
string Street { get; set; }
string StreetNo { get; set; }
string? Box { get; set; }
string City { get; set; }
string Region { get; set; }
string Country { get; set; }
}
public class AddressType : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class EmailAddress : IEntity
{
public int Id { get; set; }
public Organization Organization { get; set; } = null!;
public int OrganizationId { get; set; }
public Person Person { get; set; } = null!;
public int PersonId { get; set; }
public string Email { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class PhoneNumber : IEntity
{
public int Id { get; set; }
public Organization Organization { get; set; } = null!;
public int OrganizationId { get; set; }
public Person Person { get; set; } = null!;
public int PersonId { get; set; }
public string Phone { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Product : IEntity
{
public Product()
{
Attributes = new HashSet<ProductAttribute>();
Variants = new HashSet<Product>();
BulkPrices = new HashSet<ProductBulkPrice>();
Resources = new HashSet<ProductResource>();
Discounts = new HashSet<Discount>();
}
public int Id { get; set; }
public ProductType ProductType { get; set; } = null!;
public int ProductTypeId { get; set; }
public string Name { get; set; } = null!;
public string Sku { get; set; } = null!;
public string Description { get; set; } = null!;
public ProductCategory? Category { get; set; }
public int? CategoryId { get; set; }
public decimal Price { get; set; }
public OrderUnit? Unit { get; set; }
public int? UnitId { get; set; }
public decimal? CompareAtPrice { get; set; }
//public ProductAvailability Availability { get; set; } = ProductAvailability.Available;
//public int InStockNo { get; set; }
//public Listing IsListed { get; set; } = Listing.NotListed;
public bool HasVariants { get; set; }
public Product? BaseProduct { get; set; }
public int? BaseProductId { get; set; }
public ICollection<Product> Variants { get; set; }
public ICollection<ProductAttribute> Attributes { get; set; }
public ICollection<ProductBulkPrice> BulkPrices { get; set; }
public ICollection<ProductResource> Resources { get; set; }
public ICollection<Discount> Discounts { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Discount : IEntity
{
public int Id { get; set; }
public DiscountType Type { get; set; }
public Product Product { get; set; } = null!;
public int ProductId { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public string DiscountCode { get; set; } = null!;
public int? MaxUses { get; set; }
public int? MaxUsesPerPerson { get; set; }
public double? UnitPrice { get; set; }
public int? MinUnits { get; set; }
public int? MaxUnits { get; set; }
public decimal? Quantity { get; set; }
public double? BulkPrice { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public enum DiscountType
{
UnitDiscount,
BulkDiscount
}
public class ProductType : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ProductBulkPrice : IEntity
{
public int Id { get; set; }
public Product Product { get; set; } = null!;
public int ProductId { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public double Quantity { get; set; }
public decimal Price { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ProductResource : IEntity
{
public int Id { get; set; }
public Product Product { get; set; } = null!;
public int ProductId { get; set; }
public ResourceType? ResourceType { get; set; }
public int? ResourceTypeId { get; set; }
public Resource? Resource { get; set; }
public int? ResourceId { get; set; }
public ResourceGroup? ResourceGroup { get; set; }
public int? ResourceGroupId { get; set; }
public double? Quantity { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
[Table("Objects")]
public abstract class Object : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public int ObjectTypeId { get; set; }
public Organization? Organization { get; set; }
public int? OrganizationId { get; set; }
public Person? Person { get; set; }
public int? PersonId { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
[Table("Properties")]
public class Property : Object
{
public PropertyType PropertyType { get; set; } = null!;
public int PropertyTypeId { get; set; }
public PropertyAddress Address { get; set; } = null!;
}
[Owned]
public class PropertyAddress : IAddressDetails
{
public string Street { get; set; } = null!;
public string StreetNo { get; set; } = null!;
public string ZipCode { get; set; } = null!;
public string? Box { get; set; }
public string City { get; set; } = null!;
public string Region { get; set; } = null!;
public string Country { get; set; } = null!;
public Address? Address { get; set; }
}
public class PropertyType
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ProductCategory : IEntity, IHasChildren<ProductCategory>
{
public ProductCategory()
{
ChildItems = new HashSet<ProductCategory>();
Products = new HashSet<Product>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public ProductCategory? Parent { get; set; }
public int? ProductCategoryId { get; set; }
public ICollection<ProductCategory> ChildItems { get; set; }
public ICollection<Product> Products { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ProductAttribute : IEntity
{
public int Id { get; set; }
public Product Product { get; set; } = null!;
public int ProductId { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public string Value { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Order : IEntity, IOrder
{
public Order()
{
Items = new HashSet<OrderItem>();
}
public int Id { get; set; }
public OrderType OrderType { get; set; } = null!;
public int OrderTypeId { get; set; }
public OrderStatus Status { get; set; } = null!;
public int StatusId { get; set; }
public Detail ContractDetail { get; set; } = null!;
public Detail BillingDetail { get; set; } = null!;
public Detail DeliveryDetail { get; set; } = null!;
public ICollection<OrderItem> Items { get; set; }
public decimal SubTotal { get; set; }
public decimal? Vat { get; set; }
public decimal Total { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
[Owned]
public class Detail
{
public Organization? Organization { get; set; }
public int? OrganizationId { get; set; }
public Person? Person { get; set; }
public int? PersonId { get; set; }
public Address? Address { get; set; }
public int? AddressId { get; set; }
public PhoneNumber? PhoneNumber { get; set; }
public int? PhoneNumberId { get; set; }
public EmailAddress? EmailAddress { get; set; }
public int? EmailAddressId { get; set; }
}
public class OrderType : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class OrderStatus : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class OrderItem : IEntity, IOrderItem
{
public int Id { get; set; }
public Order Order { get; set; } = null!;
public int OrderId { get; set; }
public Product? Product { get; set; }
public int? ProductId { get; set; }
public decimal? UnitPrice { get; set; }
public decimal? FixedPrice { get; set; }
public double Quantity { get; set; }
public OrderUnit? Unit { get; set; }
public int? UnitId { get; set; }
public decimal Total { get; set; }
public Object? Object { get; set; }
public int? ObjectId { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Delivery : IEntity
{
public Delivery()
{
Items = new HashSet<DeliveryItem>();
ResourceAllocations = new HashSet<ResourceAllocation>();
}
public int Id { get; set; }
public Order? Order { get; set; }
public int? OrderId { get; set; }
public DeliveryStatus Status { get; set; } = null!;
public int? DeliveryStatusId { get; set; }
public Detail DeliveryDetail { get; set; } = null!;
public DateTime StartDate { get; set; }
public DateTime? EndDate { get; set; }
public DateTime? PlannedStartDate { get; set; }
public DateTime? PlannedEndDate { get; set; }
public ICollection<DeliveryItem> Items { get; set; }
public ICollection<ResourceAllocation> ResourceAllocations { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class DeliveryStatus : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class DeliveryItem : IEntity, IOrderItem
{
public int Id { get; set; }
public Delivery Delivery { get; set; } = null!;
public int DeliveryId { get; set; }
public OrderItem? OrderItem { get; set; }
public int OrderItemId { get; set; }
public Product? Product { get; set; }
public int? ProductId { get; set; }
public decimal? UnitPrice { get; set; }
public decimal? FixedPrice { get; set; }
public double Quantity { get; set; }
public OrderUnit? Unit { get; set; }
public int? UnitId { get; set; }
public decimal Total { get; set; }
public Object? Object { get; set; }
public int? ObjectId { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Invoice : IEntity
{
public Invoice()
{
Items = new HashSet<InvoiceItem>();
}
public int Id { get; set; }
public InvoiceType InvoiceType { get; set; } = null!;
public int InvoiceTypeId { get; set; }
public Order? Order { get; set; }
public int? OrderId { get; set; }
public Delivery? Delivery { get; set; }
public int? DeliveryId { get; set; }
public InvoiceStatus Status { get; set; } = null!;
public int StatusId { get; set; }
public Detail BillingDetail { get; set; } = null!;
public ICollection<InvoiceItem> Items { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class InvoiceType : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class InvoiceStatus : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class InvoiceItem : IEntity, IOrderItem
{
public int Id { get; set; }
public Invoice Invoice { get; set; } = null!;
public DeliveryItem? OrderItem { get; set; }
public int? OrderItemId { get; set; }
public DeliveryItem? DeliveryItem { get; set; }
public int? DeliveryItemId { get; set; }
public Product? Product { get; set; }
public int? ProductId { get; set; }
public decimal? UnitPrice { get; set; }
public decimal? FixedPrice { get; set; }
public double Quantity { get; set; }
public OrderUnit? Unit { get; set; }
public int? UnitId { get; set; }
public decimal Total { get; set; }
public Object? Object { get; set; }
public int? ObjectId { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public interface IOrder
{
decimal SubTotal { get; set; }
decimal? Vat { get; set; }
decimal Total { get; set; }
}
public interface IOrderItem
{
Product? Product { get; set; }
decimal? UnitPrice { get; set; }
decimal? FixedPrice { get; set; }
double Quantity { get; set; }
OrderUnit? Unit { get; set; }
decimal Total { get; set; }
}
public class OrderUnit : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public bool IsDivisible { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Resource : IEntity
{
public Resource()
{
Allocations = new HashSet<ResourceAllocation>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public ResourceType ResourceType { get; set; } = null!;
public int ResourceTypeId { get; set; }
public Person? Person { get; set; }
public int? PersonId { get; set; }
public Equipment? Equipment { get; set; }
public int? EquipmentId { get; set; }
public ICollection<ResourceAllocation> Allocations { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Equipment : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public EquipmentType? EquipmentType { get; set; }
public int? EquipmentTypeId { get; set; }
public Address? Address { get; set; }
public int? AddressId { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class EquipmentType
{
public EquipmentType()
{
Equipment = new HashSet<Equipment>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public ICollection<Equipment> Equipment { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? EditDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ResourceType : IEntity, IHasChildren<ResourceType>
{
public ResourceType()
{
Resources = new HashSet<Resource>();
ChildItems = new HashSet<ResourceType>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public ResourceType? Parent { get; set; }
public int? ParentId { get; set; }
public ICollection<ResourceType> ChildItems { get; set; }
public ICollection<Resource> Resources { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ResourceGroup : IEntity
{
public ResourceGroup()
{
MemberResources = new HashSet<ResourceGroupMember>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public ICollection<ResourceGroupMember> MemberResources { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ResourceGroupMember : IEntity
{
public int Id { get; set; }
public ResourceGroup ResourceGroup { get; set; } = null!;
public int ResourceGroupId { get; set; }
public Resource? Resource { get; set; }
public int? ResourceId { get; set; }
public Resource? ResourceType { get; set; }
public int? ResourceTypeId { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ResourceAllocation : IEntity
{
public int Id { get; set; }
public Resource Resource { get; set; } = null!;
public int ResourceId { get; set; }
public Delivery? Delivery { get; set; }
public int? DeliveryId { get; set; }
public DeliveryItem? DeliveryItem { get; set; }
public int? DeliveryItemId { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
} |
And provider and EF Core version? |
@ErikEJ Sorry <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.1" />
</ItemGroup> |
And your DbContextOtions? |
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using ResourcePlanner;
using System;
using System.IO;
var hostBuilder = new HostBuilder()
.ConfigureAppConfiguration((hostingContext, configBuilder) =>
{
configBuilder.SetBasePath(Directory.GetCurrentDirectory());
configBuilder.AddJsonFile($"appsettings.json");
configBuilder.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true);
})
.ConfigureServices((hostingContext, services) =>
{
services.AddDbContext<ResourcesContext>(c =>
{
c.UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()))
.EnableSensitiveDataLogging()
.UseSqlite(hostingContext.Configuration.GetConnectionString("DefaultConnection"));
});
services.AddHostedService<DataService>();
});
await hostBuilder.RunConsoleAsync(); |
It did work yesterday, strangely. Then I re-opened it, made some changes, ran it and now It does not work. |
It fails when the database is being created. |
What does the connection string resolve to?? |
{
"ConnectionStrings": {
"DefaultConnection": "Data Source=db.sqlite;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
} |
@ErikEJ Have you figured out what is wrong? I was hoping there would be a more descriptive message giving me a hint. |
@RobertSundstrom Looks like it means there is a bug. @AndriySvyryd Runnable repro below. using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.Extensions.Logging;
public class ResourcesContext : DbContext
{
private static ILoggerFactory ContextLoggerFactory
=> LoggerFactory.Create(b => b.AddConsole());//.SetMinimumLevel(LogLevel.Information));
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseLoggerFactory(ContextLoggerFactory)
.EnableSensitiveDataLogging()
.UseSqlite("Data Source = test.db");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Person>()
.HasMany(p => p.Organizations)
.WithMany(o => o.Persons)
.UsingEntity<OrganizationPerson>(
j => j.HasOne(m => m.Organization).WithMany(o => o.OrganizationPersons),
j => j.HasOne(m => m.Person).WithMany(o => o.OrganizationPersons));
}
#nullable disable
public DbSet<Person> Persons { get; set; }
public DbSet<Organization> Organizations { get; set; }
public DbSet<OrganizationPerson> OrganizationPersons { get; set; }
public DbSet<PersonType> PersonTypes { get; set; }
public DbSet<Equipment> Equipment { get; set; }
public DbSet<EquipmentType> EquipmentTypes { get; set; }
public DbSet<Address> Addresses { get; set; }
public DbSet<AddressType> AddressTypes { get; set; }
public DbSet<PhoneNumber> PhoneNumbers { get; set; }
public DbSet<EmailAddress> EmailAddresses { get; set; }
public DbSet<Product> Products { get; set; }
public DbSet<ProductType> ProductTypes { get; set; }
public DbSet<ProductCategory> ProductCategories { get; set; }
public DbSet<ProductAttribute> ProductAttributes { get; set; }
public DbSet<ProductBulkPrice> ProductBulkPrices { get; set; }
public DbSet<ProductResource> ProductResources { get; set; }
public DbSet<Discount> Discounts { get; set; }
public DbSet<OrderUnit> OrderUnits { get; set; }
public DbSet<Object> Objects { get; set; }
public DbSet<Property> Properties { get; set; }
public DbSet<PropertyType> PropertyTypes { get; set; }
public DbSet<Order> Orders { get; set; }
public DbSet<OrderType> OrderTypes { get; set; }
public DbSet<OrderStatus> OrderStatuses { get; set; }
public DbSet<OrderItem> OrderItems { get; set; }
public DbSet<Delivery> Deliveries { get; set; }
public DbSet<DeliveryStatus> DeliveryStatuses { get; set; }
public DbSet<DeliveryItem> DeliveryItems { get; set; }
public DbSet<Invoice> Invoices { get; set; }
public DbSet<InvoiceType> InvoiceTypes { get; set; }
public DbSet<InvoiceStatus> InvoiceStatuses { get; set; }
public DbSet<InvoiceItem> InvoiceItems { get; set; }
public DbSet<Resource> Resources { get; set; }
public DbSet<ResourceType> ResourceTypes { get; set; }
public DbSet<ResourceGroup> ResourceGroups { get; set; }
public DbSet<ResourceGroupMember> ResourceGroupMembers { get; set; }
public DbSet<ResourceAllocation> ResourceAllocations { get; set; }
#nullable enable
}
public interface IEntity
{
int Id { get; set; }
DateTime CreationDate { get; set; }
DateTime? UpdateDate { get; set; }
bool? IsDeleted { get; set; }
DateTime? DeletionDate { get; set; }
}
public class Person : IEntity
{
public Person()
{
Organizations = new HashSet<Organization>();
OrganizationPersons = new HashSet<OrganizationPerson>();
Addresses = new HashSet<Address>();
EmailAddresses = new HashSet<EmailAddress>();
PhoneNumbers = new HashSet<PhoneNumber>();
Objects = new HashSet<Object>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string FirstName { get; set; } = null!;
public string? MiddleName { get; set; }
public string GivenName { get; set; } = null!;
public string? Nickname { get; set; }
public string LastName { get; set; } = null!;
public string Ssn { get; set; } = null!;
public DateTime? BirthDate { get; set; } = null!;
public bool? IsDeceased { get; set; } = null!;
public DateTime? DeathDate { get; set; } = null!;
public ICollection<Organization> Organizations { get; set; }
public ICollection<OrganizationPerson> OrganizationPersons { get; set; }
public ICollection<Address> Addresses { get; set; }
public ICollection<EmailAddress> EmailAddresses { get; set; }
public ICollection<PhoneNumber> PhoneNumbers { get; set; }
public ICollection<Object> Objects { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Organization : IEntity
{
public Organization()
{
Persons = new HashSet<Person>();
OrganizationPersons = new HashSet<OrganizationPerson>();
Addresses = new HashSet<Address>();
EmailAddresses = new HashSet<EmailAddress>();
PhoneNumbers = new HashSet<PhoneNumber>();
Objects = new HashSet<Object>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string OrgNo { get; set; } = null!;
public string VatNo { get; set; } = null!;
public ICollection<Person> Persons { get; set; }
public ICollection<OrganizationPerson> OrganizationPersons { get; set; }
public ICollection<Address> Addresses { get; set; }
public ICollection<EmailAddress> EmailAddresses { get; set; }
public ICollection<PhoneNumber> PhoneNumbers { get; set; }
public ICollection<Object> Objects { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class OrganizationPerson : IEntity
{
public int Id { get; set; }
public Organization Organization { get; set; } = null!;
public int OrganizationId { get; set; }
public Person Person { get; set; } = null!;
public int PersonId { get; set; }
public PersonType PersonType { get; set; } = null!;
public int PersonTypeId { get; set; }
public string? Title { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public interface IHasChildren<T>
{
public T? Parent { get; set; }
public ICollection<T> ChildItems { get; set; }
}
public class PersonType : IEntity, IHasChildren<PersonType>
{
public PersonType()
{
ChildItems = new HashSet<PersonType>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public PersonType? Parent { get; set; }
public int? ParentId { get; set; }
public ICollection<PersonType> ChildItems { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Address : IEntity, IAddressDetails
{
public int Id { get; set; }
public Organization Organization { get; set; } = null!;
public int OrganizationId { get; set; }
public Person Person { get; set; } = null!;
public int PersonId { get; set; }
public AddressType AddressType { get; set; } = null!;
public int AddressTypeId { get; set; }
public string? CareOf { get; set; }
public string Street { get; set; } = null!;
public string StreetNo { get; set; } = null!;
public string ZipCode { get; set; } = null!;
public string? Box { get; set; }
public string City { get; set; } = null!;
public string Region { get; set; } = null!;
public string Country { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public interface IAddressDetails
{
string Street { get; set; }
string StreetNo { get; set; }
string? Box { get; set; }
string City { get; set; }
string Region { get; set; }
string Country { get; set; }
}
public class AddressType : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class EmailAddress : IEntity
{
public int Id { get; set; }
public Organization Organization { get; set; } = null!;
public int OrganizationId { get; set; }
public Person Person { get; set; } = null!;
public int PersonId { get; set; }
public string Email { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class PhoneNumber : IEntity
{
public int Id { get; set; }
public Organization Organization { get; set; } = null!;
public int OrganizationId { get; set; }
public Person Person { get; set; } = null!;
public int PersonId { get; set; }
public string Phone { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Product : IEntity
{
public Product()
{
Attributes = new HashSet<ProductAttribute>();
Variants = new HashSet<Product>();
BulkPrices = new HashSet<ProductBulkPrice>();
Resources = new HashSet<ProductResource>();
Discounts = new HashSet<Discount>();
}
public int Id { get; set; }
public ProductType ProductType { get; set; } = null!;
public int ProductTypeId { get; set; }
public string Name { get; set; } = null!;
public string Sku { get; set; } = null!;
public string Description { get; set; } = null!;
public ProductCategory? Category { get; set; }
public int? CategoryId { get; set; }
public decimal Price { get; set; }
public OrderUnit? Unit { get; set; }
public int? UnitId { get; set; }
public decimal? CompareAtPrice { get; set; }
//public ProductAvailability Availability { get; set; } = ProductAvailability.Available;
//public int InStockNo { get; set; }
//public Listing IsListed { get; set; } = Listing.NotListed;
public bool HasVariants { get; set; }
public Product? BaseProduct { get; set; }
public int? BaseProductId { get; set; }
public ICollection<Product> Variants { get; set; }
public ICollection<ProductAttribute> Attributes { get; set; }
public ICollection<ProductBulkPrice> BulkPrices { get; set; }
public ICollection<ProductResource> Resources { get; set; }
public ICollection<Discount> Discounts { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Discount : IEntity
{
public int Id { get; set; }
public DiscountType Type { get; set; }
public Product Product { get; set; } = null!;
public int ProductId { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public string DiscountCode { get; set; } = null!;
public int? MaxUses { get; set; }
public int? MaxUsesPerPerson { get; set; }
public double? UnitPrice { get; set; }
public int? MinUnits { get; set; }
public int? MaxUnits { get; set; }
public decimal? Quantity { get; set; }
public double? BulkPrice { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public enum DiscountType
{
UnitDiscount,
BulkDiscount
}
public class ProductType : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ProductBulkPrice : IEntity
{
public int Id { get; set; }
public Product Product { get; set; } = null!;
public int ProductId { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public double Quantity { get; set; }
public decimal Price { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ProductResource : IEntity
{
public int Id { get; set; }
public Product Product { get; set; } = null!;
public int ProductId { get; set; }
public ResourceType? ResourceType { get; set; }
public int? ResourceTypeId { get; set; }
public Resource? Resource { get; set; }
public int? ResourceId { get; set; }
public ResourceGroup? ResourceGroup { get; set; }
public int? ResourceGroupId { get; set; }
public double? Quantity { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
[Table("Objects")]
public abstract class Object : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public int ObjectTypeId { get; set; }
public Organization? Organization { get; set; }
public int? OrganizationId { get; set; }
public Person? Person { get; set; }
public int? PersonId { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
[Table("Properties")]
public class Property : Object
{
public PropertyType PropertyType { get; set; } = null!;
public int PropertyTypeId { get; set; }
public PropertyAddress Address { get; set; } = null!;
}
[Owned]
public class PropertyAddress : IAddressDetails
{
public string Street { get; set; } = null!;
public string StreetNo { get; set; } = null!;
public string ZipCode { get; set; } = null!;
public string? Box { get; set; }
public string City { get; set; } = null!;
public string Region { get; set; } = null!;
public string Country { get; set; } = null!;
public Address? Address { get; set; }
}
public class PropertyType
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ProductCategory : IEntity, IHasChildren<ProductCategory>
{
public ProductCategory()
{
ChildItems = new HashSet<ProductCategory>();
Products = new HashSet<Product>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public ProductCategory? Parent { get; set; }
public int? ProductCategoryId { get; set; }
public ICollection<ProductCategory> ChildItems { get; set; }
public ICollection<Product> Products { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ProductAttribute : IEntity
{
public int Id { get; set; }
public Product Product { get; set; } = null!;
public int ProductId { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public string Value { get; set; } = null!;
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Order : IEntity, IOrder
{
public Order()
{
Items = new HashSet<OrderItem>();
}
public int Id { get; set; }
public OrderType OrderType { get; set; } = null!;
public int OrderTypeId { get; set; }
public OrderStatus Status { get; set; } = null!;
public int StatusId { get; set; }
public Detail ContractDetail { get; set; } = null!;
public Detail BillingDetail { get; set; } = null!;
public Detail DeliveryDetail { get; set; } = null!;
public ICollection<OrderItem> Items { get; set; }
public decimal SubTotal { get; set; }
public decimal? Vat { get; set; }
public decimal Total { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
[Owned]
public class Detail
{
public Organization? Organization { get; set; }
public int? OrganizationId { get; set; }
public Person? Person { get; set; }
public int? PersonId { get; set; }
public Address? Address { get; set; }
public int? AddressId { get; set; }
public PhoneNumber? PhoneNumber { get; set; }
public int? PhoneNumberId { get; set; }
public EmailAddress? EmailAddress { get; set; }
public int? EmailAddressId { get; set; }
}
public class OrderType : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class OrderStatus : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class OrderItem : IEntity, IOrderItem
{
public int Id { get; set; }
public Order Order { get; set; } = null!;
public int OrderId { get; set; }
public Product? Product { get; set; }
public int? ProductId { get; set; }
public decimal? UnitPrice { get; set; }
public decimal? FixedPrice { get; set; }
public double Quantity { get; set; }
public OrderUnit? Unit { get; set; }
public int? UnitId { get; set; }
public decimal Total { get; set; }
public Object? Object { get; set; }
public int? ObjectId { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Delivery : IEntity
{
public Delivery()
{
Items = new HashSet<DeliveryItem>();
ResourceAllocations = new HashSet<ResourceAllocation>();
}
public int Id { get; set; }
public Order? Order { get; set; }
public int? OrderId { get; set; }
public DeliveryStatus Status { get; set; } = null!;
public int? DeliveryStatusId { get; set; }
public Detail DeliveryDetail { get; set; } = null!;
public DateTime StartDate { get; set; }
public DateTime? EndDate { get; set; }
public DateTime? PlannedStartDate { get; set; }
public DateTime? PlannedEndDate { get; set; }
public ICollection<DeliveryItem> Items { get; set; }
public ICollection<ResourceAllocation> ResourceAllocations { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class DeliveryStatus : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class DeliveryItem : IEntity, IOrderItem
{
public int Id { get; set; }
public Delivery Delivery { get; set; } = null!;
public int DeliveryId { get; set; }
public OrderItem? OrderItem { get; set; }
public int OrderItemId { get; set; }
public Product? Product { get; set; }
public int? ProductId { get; set; }
public decimal? UnitPrice { get; set; }
public decimal? FixedPrice { get; set; }
public double Quantity { get; set; }
public OrderUnit? Unit { get; set; }
public int? UnitId { get; set; }
public decimal Total { get; set; }
public Object? Object { get; set; }
public int? ObjectId { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Invoice : IEntity
{
public Invoice()
{
Items = new HashSet<InvoiceItem>();
}
public int Id { get; set; }
public InvoiceType InvoiceType { get; set; } = null!;
public int InvoiceTypeId { get; set; }
public Order? Order { get; set; }
public int? OrderId { get; set; }
public Delivery? Delivery { get; set; }
public int? DeliveryId { get; set; }
public InvoiceStatus Status { get; set; } = null!;
public int StatusId { get; set; }
public Detail BillingDetail { get; set; } = null!;
public ICollection<InvoiceItem> Items { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class InvoiceType : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class InvoiceStatus : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class InvoiceItem : IEntity, IOrderItem
{
public int Id { get; set; }
public Invoice Invoice { get; set; } = null!;
public DeliveryItem? OrderItem { get; set; }
public int? OrderItemId { get; set; }
public DeliveryItem? DeliveryItem { get; set; }
public int? DeliveryItemId { get; set; }
public Product? Product { get; set; }
public int? ProductId { get; set; }
public decimal? UnitPrice { get; set; }
public decimal? FixedPrice { get; set; }
public double Quantity { get; set; }
public OrderUnit? Unit { get; set; }
public int? UnitId { get; set; }
public decimal Total { get; set; }
public Object? Object { get; set; }
public int? ObjectId { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public interface IOrder
{
decimal SubTotal { get; set; }
decimal? Vat { get; set; }
decimal Total { get; set; }
}
public interface IOrderItem
{
Product? Product { get; set; }
decimal? UnitPrice { get; set; }
decimal? FixedPrice { get; set; }
double Quantity { get; set; }
OrderUnit? Unit { get; set; }
decimal Total { get; set; }
}
public class OrderUnit : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public bool IsDivisible { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Resource : IEntity
{
public Resource()
{
Allocations = new HashSet<ResourceAllocation>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public ResourceType ResourceType { get; set; } = null!;
public int ResourceTypeId { get; set; }
public Person? Person { get; set; }
public int? PersonId { get; set; }
public Equipment? Equipment { get; set; }
public int? EquipmentId { get; set; }
public ICollection<ResourceAllocation> Allocations { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Equipment : IEntity
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public EquipmentType? EquipmentType { get; set; }
public int? EquipmentTypeId { get; set; }
public Address? Address { get; set; }
public int? AddressId { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class EquipmentType
{
public EquipmentType()
{
Equipment = new HashSet<Equipment>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public ICollection<Equipment> Equipment { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? EditDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ResourceType : IEntity, IHasChildren<ResourceType>
{
public ResourceType()
{
Resources = new HashSet<Resource>();
ChildItems = new HashSet<ResourceType>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public ResourceType? Parent { get; set; }
public int? ParentId { get; set; }
public ICollection<ResourceType> ChildItems { get; set; }
public ICollection<Resource> Resources { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ResourceGroup : IEntity
{
public ResourceGroup()
{
MemberResources = new HashSet<ResourceGroupMember>();
}
public int Id { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public ICollection<ResourceGroupMember> MemberResources { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ResourceGroupMember : IEntity
{
public int Id { get; set; }
public ResourceGroup ResourceGroup { get; set; } = null!;
public int ResourceGroupId { get; set; }
public Resource? Resource { get; set; }
public int? ResourceId { get; set; }
public Resource? ResourceType { get; set; }
public int? ResourceTypeId { get; set; }
public string Name { get; set; } = null!;
public string? Description { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class ResourceAllocation : IEntity
{
public int Id { get; set; }
public Resource Resource { get; set; } = null!;
public int ResourceId { get; set; }
public Delivery? Delivery { get; set; }
public int? DeliveryId { get; set; }
public DeliveryItem? DeliveryItem { get; set; }
public int? DeliveryItemId { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
public DateTime? UpdateDate { get; set; }
public bool? IsDeleted { get; set; }
public DateTime? DeletionDate { get; set; }
}
public class Program
{
public static void Main()
{
using (var context = new ResourcesContext())
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
}
}
} |
Whar does this mean? What is wrong with my model?
The text was updated successfully, but these errors were encountered: