Updated readme and added new sample project

This commit is contained in:
Koen Bekkenutte
2021-05-31 04:05:38 +08:00
parent 07043931f2
commit a33fbfeddf
12 changed files with 328 additions and 8 deletions
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using EntityFrameworkCore.Projections.Extensions;
using Microsoft.EntityFrameworkCore;
using ReadmeSample.Entities;
namespace ReadmeSample
{
public class ApplicationDbContext : DbContext
{
public DbSet<User> Users { get; set; }
public DbSet<Product> Products { get; set; }
public DbSet<Order> Orders { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Server=(localdb)\\MSSQLLocalDB;Database=ReadmeSample;Trusted_Connection=True");
optionsBuilder.UseProjections();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<OrderItem>().HasKey(x => new { x.OrderId, x.ProductId });
}
}
}