Apply the migrations to the database
dotnet ef database update --connection "<your connection string>"
Add migraion
dotnet ef migrations add InitialCreate
Remove latest migration instructions (cannot remove once applied)
dotnet ef migrations remove InitialCreate --force
ActivityContextFactory
using Microsoft.EntityFrameworkCore.Design;
namespace Activity.Infrastructure;
public class ActivityContextFactory: IDesignTimeDbContextFactory<ActivityContext> {
public ActivityContext CreateDbContext(string[] args) {
var optionsBuilder = new DbContextOptionsBuilder<ActivityContext>().UseSqlServer();
return new ActivityContext(optionsBuilder.Options);
}
}
csproj
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
</ItemGroup>
"server=localhost,9301;database=skd;uid=sa;pwd=DevDevDude119#;MultipleActiveResultSets=True;Encrypt=false;TrustServerCertificate=False;Connection Timeout=30;"
namespace Activity.Domain.Model;
public abstract class BaseEntity {
public Guid Id { get; set; }
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset? RemovedAt { get; set; }
}
public class Company : BaseEntity {
public string Name { get; private set; } = null!;
public string? Address { get; private set; } = null!;
public string Email { get; private set; } = null!;
public string Phone { get; private set; } = null!;
public decimal VATPercent { get; private set; }
public string? CurrencyCode { get; private set; } = null!;
public string? PaymentTerms { get; private set; } = null!;
public List<Invoice> Invoices { get; set; } = new();
public static int MAX_COMPANY_NAME_LEN = 100;
public static int MAX_ADDRESS_LEN = 500;
public static int MAX_EMAIL_LEN = 100;
public static int MAX_PHONE_LEN = 20;
public static int MAX_CURRENCY_CODE_LEN = 3;
public static int MAX_PAYMENT_TERMS_LEN = 100;
}
public class Client : BaseEntity {
public string CompanyName { get; set; } = null!;
public string Address { get; set; } = null!;
public string Email { get; set; } = null!;
public string Phone { get; set; } = null!;
public string PaymentTerms { get; set; } = null!;
public List<Invoice> Invoices { get; set; } = new();
public List<TimeEntry> TimeEntries { get; set; } = new();
public List<Project> Projects { get; set; } = new();
public static int MAX_COMPANY_NAME_LEN = 100;
public static int MAX_ADDRESS_LEN = 500;
public static int MAX_EMAIL_LEN = 100;
public static int MAX_PHONE_LEN = 20;
}
namespace Activity.Domain.Model;
public class User: BaseEntity {
public string Name { get; set; } = null!;
public string Email { get; set; } = null!;
public List<TimeEntry> TimeEntries { get; set; } = new();
public static int MAX_NAME_LEN = 100;
public static int MAX_EMAIL_LEN = 100;
}
public class Invoice: BaseEntity {
public int Year { get; set; }
public int Number { get; set; }
public DateTime InvoiceDate { get; set; }
public DateTime DueDate { get; set; }
public decimal Subtotal { get; set; }
public decimal Tax { get; set; }
public decimal Total { get; set; }
public Guid ClientId { get; set; }
public Client Client { get; set; } = null!;
public Guid CompanyId { get; set; }
public Company Company { get; set; } = null!;
public List<InvoiceLineItem> LineItems { get; set; } = new();
}
public class InvoiceLineItem: BaseEntity {
public decimal Price { get; set; }
public decimal Quantity { get; set; }
public string Unit { get; set; }= null!;
public decimal LineItemTotal { get; set; }
public string Description { get; set; }= null!;
public Guid InvoiceId { get; set; }
public Invoice Invoice { get; set; }= null!;
public List<TimeEntry> TimeEntries { get; set; } = new();
}
public class Project: BaseEntity {
public string Code { get; set; } = null!;
public string Name { get; set; } = null!;
public string Description { get; set; } = null!;
public Guid ClientId { get; set; }
public Client Client { get; set; } = null!;
public List<TimeEntry> TimeEntries { get; set; } = new();
}
public class Receipt : BaseEntity {
public int Year { get; set; }
public int Number { get; set; }
public DateTime ReceiptDate { get; set; }
public decimal Amount { get; set; }
public decimal Tax { get; set; }
public decimal Total { get; set; }
public string Description { get; set; } = null!;
public Invoice Invoice { get; set; } = null!;
}
namespace Activity.Domain.Model;
public class TimeEntry : BaseEntity {
public DateTimeOffset Start { get; set; }
public DateTimeOffset? End { get; set; }
public decimal Hours { get; set; }
public string Description { get; set; } = null!;
public int ClientId { get; set; }
public Client Client { get; set; } = null!;
public Guid DeveloperId { get; set; }
public Developer Developer { get; set; } = null!;
public Guid ProjectId { get; set; }
public Project Project { get; set; } = null!;
public InvoiceLineItem? InvoiceLineItem { get; set; }
}
Folder structure
CreateCompnay
UpdateCompany
CreateClient
UpdateClient
CreateClientProject
UpdateClientProject
RemoveClientProject
RestoreCleintProject
CreateUser
UpdateUser
CreateTimeEntry
UpdateTimeEntry
RemoveTimeEntry
RestoreTimeEntry
CreateInvoice
CreateReceipt
- Domain
- Models
- Company.cs
- Client.cs
- Project.cs
- TimeEntry.cs
- User.cs
- Invoice.cs
- InvoiceLineItem.cs
- Receipt.cs
- Infrastructure
- ActivityDbContext.cs
- Configuration
- CompanyConfiguration.cs
- ProjectConfiguration.cs
- ClientConfiguration.cs
- UserConfiguration.cs
- TimeEntryConfiguration.cs
- InvoiceConfiguration.cs
- IncoiceLineItemConfiguration.cs
- ReceiptConfiguration.cs
- ActivityDbContextFactory.cs
- Application
- Result
- Result.cs
- Error.cs
- Mutations
- CreateCompany
- CreateCompany.cs
- CreateCompanyInput.cs
- CreateCompanyPayload.cs
- CreateCompanyValidator.cs
- UpdateCompany
- UpdateCompany.cs
- UpdateCompanyInput.cs
- UpdateCompanyPayload.cs
- UpdateCompanyValidator.cs
- RemoveCompany
- RestoreCompany
- CreateClient
- CreateClient.cs
- CreateClientInput.cs
- CreateClientPayload.cs
- UpdateClient
- CreateClientProject
- UpdateClientProject
- RemoveClientProject
- RestoreClietntProject
- CreateUser
- UpdateUser
- CreateTimeEntry
- UpdateTimeEntry
- RemoveTimeEntry
- RestoreTimeEntry
- CreateInvoice
- CreateReceipt
- Queries
- Client
- ClientDetailQuery.cs
- ClientDetailQueryInput.cs
- ClientDetailQueryPayload.cs
- ClientTimeEntriesForMonthQuery.cs
- ClientTimeEntriesForMonthQueryInput.cs
- ClientTimeEntriesForMonthQueryPaylaod.cs
- User
- UserTimeEntriesFormMonth
- UserTimeEntriesForMonthInput
- UserTimeEntriesForMonthPayload
- Project
- ProjectTimeEntriesForMonth
- ProjectTimeEntriesForMonthInput
- ProjectTimeEntriesForMonthPayload
- Api
- Program.cs
- Resolvers
- Mutation
- Muation.cs
- CompanyMutation.cs
- ClientMutation.cs
- InvoiceMutation.cs
- ReceiptMutation.cs
- Query
- Query.cs
- ClientQuery.cs
- UserQuery.cs
- ProjectQuery.cs
- Subscriptions
- Configuration
- DependencyInjection.cs
- Appsettings.cs
namespace App; public static class RawLotParts { public static string BPA2A2124012001 = @" KU5A-286B86-BA LBL LNR P/U BOX 6 0 MB3C-2263-BH TUB ASY FRT WHL BRK 6 0 N1WB-17682-UED5JNV MIR ASY RV O/S 6 0 MB3A-12A692-DC BRKT ASY ENG ELETR CONTR PROCS 6 0 W716592-S300 RIVET PUSH PIN 7.5X7.2 PLA 12 0 W717491-S450B BOLT&WSHR M6X25 HX PIL PTC FL 8 12 0
Feb 13, 2024Add script
Aug 28, 2023Remove all list runtimes dotnet --list-runtimes nuke dotnet sudo rm -rf /usr/local/share/dotnet Remove version Replace version with the version of dotnet you want to remove
Feb 15, 2023Create and populate tables select * from pg_catalog.pg_tables where schemaname = 'public'; drop table menu_item; drop table menu_category; drop table pricing; drop table review; create table
Feb 3, 2023or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up