Sales - svetlilaloli/EntityFramework-SoftUni GitHub Wiki
Practice: Code-First
1. Sales Database
Create a database for storing data about sales using the Code First approach.
Constraints
Your namespaces should be:
- P03_SalesDatabase
- P03_SalesDatabase.Data
- P03_SalesDatabase.Data.Models
Your classes should be:
- SalesContext – your DbContext
- Product:
- ProductId
- Name (up to 50 characters, unicode)
- Quantity (real number)
- Price
- Sales
- Customer:
- CustomerId
- Name (up to 100 characters, unicode)
- Email (up to 80 characters, not unicode)
- CreditCardNumber (string)
- Sales
- Store:
- StoreId
- Name (up to 80 characters, unicode)
- Sales
- Sale:
- SaleId
- Date
- Product
- Customer
- Store
Bonus Task
Write a seed method that fills the database with sample data (randomly generated).
2. Products Migration
To apply migrations, you will need the package:
- EntityFrameworkCore.Tools 3.1.3
For table Products add string column Description, up to 250 symbols. Use migrations. The migration should be named: "ProductsAddColumnDescription". Add a default value for the description property: "No description".
3. Sales Migration
For table Sales make Date column with default value GETDATE() function, called from the database, not the application. Use explicit migration. Do not use DateTime.Now! Name the migration "SalesAddDateDefault".
After that, open your table data and see if the default value is applied or not.