├── .gitattributes
├── .gitignore
├── Backing_Fields
└── Program.cs
├── ChangeTracker
├── ChangeTracker.csproj
├── Migrations
│ ├── 20220810171938_mig_1.Designer.cs
│ ├── 20220810171938_mig_1.cs
│ └── ETicaretContextModelSnapshot.cs
└── Program.cs
├── Code_First
├── Code_First.csproj
├── Migrations
│ ├── 20220620123417_mig_1.Designer.cs
│ ├── 20220620123417_mig_1.cs
│ ├── 20220620123433_mig_2.Designer.cs
│ ├── 20220620123433_mig_2.cs
│ ├── 20220620123516_mig_3.Designer.cs
│ ├── 20220620123516_mig_3.cs
│ ├── 20220620123526_mig_4.Designer.cs
│ ├── 20220620123526_mig_4.cs
│ └── ECommerceDbContextModelSnapshot.cs
└── Program.cs
├── Complex_Relational_Queries
├── Complex_Relational_Queries.csproj
├── Configurations
│ └── Datas.cs
├── Migrations
│ ├── 20221108154124_mig_1.Designer.cs
│ ├── 20221108154124_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Connection_Resiliency
├── Configurations
│ └── Datas.cs
├── Connection_Resiliency.csproj
├── Migrations
│ ├── 20221211004253_mig_1.Designer.cs
│ ├── 20221211004253_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Constraints
├── Constraints.csproj
├── Migrations
│ ├── 20221018174406_mig_1.Designer.cs
│ ├── 20221018174406_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Data_Concurrency
├── Configurations
│ └── Datas.cs
├── Data_Concurrency.csproj
├── Migrations
│ ├── 20221215170527_mig_1.Designer.cs
│ ├── 20221215170527_mig_1.cs
│ ├── 20221215173212_mig_2.Designer.cs
│ ├── 20221215173212_mig_2.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Data_Seeding
├── Data_Seeding.csproj
├── Migrations
│ ├── 20220929142729_mig_1.Designer.cs
│ ├── 20220929142729_mig_1.cs
│ ├── 20220929142854_mig_2.Designer.cs
│ ├── 20220929142854_mig_2.cs
│ ├── 20220929143157_mig_3.Designer.cs
│ ├── 20220929143157_mig_3.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Deleting_Related_Data
├── Deleting_Related_Data.csproj
├── Migrations
│ ├── 20220903164401_mig_1.Designer.cs
│ ├── 20220903164401_mig_1.cs
│ ├── 20220903164917_mig_2.Designer.cs
│ ├── 20220903164917_mig_2.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── EFCoreTraining.sln
├── EF_Core_7_Bulk_Update_And_Delete
├── Configurations
│ └── Datas.cs
├── EF_Core_7_Bulk_Update_And_Delete.csproj
├── Migrations
│ ├── 20221227082615_mig_1.Designer.cs
│ ├── 20221227082615_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── EF_Core_7_Entity_Splitting
├── EF_Core_7_Entity_Splitting.csproj
├── Migrations
│ ├── 20221229075654_mig_1.Designer.cs
│ ├── 20221229075654_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── EF_Core_7_Injecting_Services_Into_Entities
├── Configurations
│ └── Datas.cs
├── EF_Core_7_Injecting_Services_Into_Entities.csproj
├── Migrations
│ ├── 20221227100013_mig_1.Designer.cs
│ ├── 20221227100013_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── EF_Core_Configurations
├── EF_Core_Configurations.csproj
├── Migrations
│ ├── 20220922074018_mig_1.Designer.cs
│ ├── 20220922074018_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── EF_Core_Efficient_Querying
├── Configurations
│ └── Datas.cs
├── EF_Core_Efficient_Querying.csproj
├── Migrations
│ ├── 20221224112007_mig_1.Designer.cs
│ ├── 20221224112007_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── EF_Core_In_Memory_Database
├── EF_Core_In_Memory_Database.csproj
└── Program.cs
├── EF_Core_Logging
├── Configurations
│ └── Datas.cs
├── EF_Core_Logging.csproj
├── Migrations
│ ├── 20221201171853_mig_1.Designer.cs
│ ├── 20221201171853_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── EfCoreAdoNet
├── Configurations
│ └── Datas.cs
├── EfCoreAdoNet.csproj
├── Migrations
│ ├── 20221129154325_mig_1.Designer.cs
│ ├── 20221129154325_mig_1.cs
│ ├── 20221129163217_mig_2.Designer.cs
│ ├── 20221129163217_mig_2.cs
│ ├── 20221129163225_mig_3.Designer.cs
│ ├── 20221129163225_mig_3.cs
│ ├── 20221129163228_mig_4.Designer.cs
│ ├── 20221129163228_mig_4.cs
│ ├── 20221129163231_mig_5.Designer.cs
│ ├── 20221129163231_mig_5.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Explicit_Loading
├── Configurations
│ └── Datas.cs
├── Explicit_Loading.csproj
├── Migrations
│ ├── 20221102224435_mig_1.Designer.cs
│ ├── 20221102224435_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Functions
├── Configurations
│ └── Datas.cs
├── Functions.csproj
├── Migrations
│ ├── 20221122230042_mig_1.Designer.cs
│ ├── 20221122230042_mig_1.cs
│ ├── 20221122230105_mig_2.Designer.cs
│ ├── 20221122230105_mig_2.cs
│ ├── 20221122234402_mig_3.Designer.cs
│ ├── 20221122234402_mig_3.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Generated_Values
├── Generated_Values.csproj
├── Migrations
│ ├── 20220924160329_mig_1.Designer.cs
│ ├── 20220924160329_mig_1.cs
│ ├── 20220924161111_mig_2.Designer.cs
│ ├── 20220924161111_mig_2.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Global_Query_Filters
├── Configurations
│ └── Datas.cs
├── Global_Query_Filters.csproj
├── Migrations
│ ├── 20221206165144_mig_1.Designer.cs
│ ├── 20221206165144_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Indexes
├── Indexes - Backup.csproj
├── Indexes.csproj
├── Migrations
│ ├── 20221024204508_mig_1.Designer.cs
│ ├── 20221024204508_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Inheritance_Table_Per_Concrete_Type
├── Inheritance_Table_Per_Concrete_Type.csproj
├── Migrations
│ ├── 20221016215546_mig_1.Designer.cs
│ ├── 20221016215546_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Inheritance_Table_Per_Hierarchy
├── Inheritance_Table_Per_Hierarchy.csproj
├── Migrations
│ ├── 20221005183014_mig_1.Designer.cs
│ ├── 20221005183014_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Inheritance_Table_Per_Type
├── Inheritance_Table_Per_Type.csproj
├── Migrations
│ ├── 20221007213607_mig_1.Designer.cs
│ ├── 20221007213607_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Keyless_Entity_Types
├── Configurations
│ └── Datas.cs
├── Keyless_Entity_Types.csproj
├── Migrations
│ ├── 20221130161243_mig_1.Designer.cs
│ ├── 20221130161243_mig_1.cs
│ ├── 20221130171307_mig_2.Designer.cs
│ ├── 20221130171307_mig_2.cs
│ ├── 20221130171902_mig_3.Designer.cs
│ ├── 20221130171902_mig_3.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Lazy_Loading
├── Configurations
│ └── Datas.cs
├── Lazy_Loading.csproj
├── Migrations
│ ├── 20221105171703_mig_1.Designer.cs
│ ├── 20221105171703_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Lesson1
├── Lesson1.csproj
├── ORM.cs
├── Program.cs
└── appsettings.json
├── Lesson9
├── Lesson9.csproj
├── Migrations
│ ├── 20220704202121_mig_1.Designer.cs
│ ├── 20220704202121_mig_1.cs
│ └── ETicaretContextModelSnapshot.cs
└── Program.cs
├── Loading_Related_Data
├── Configurations
│ └── Datas.cs
├── Loading_Related_Data.csproj
├── Migrations
│ ├── 20221102135214_mig_1.Designer.cs
│ ├── 20221102135214_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
└── Program.cs
├── Many_to_Many_Relationship
├── Many_to_Many_Relationship.csproj
└── Program.cs
├── ORM_SQL_İzalasyonu
├── Models
│ ├── AlphabeticalListOfProduct.cs
│ ├── Category.cs
│ ├── CategorySalesFor1997.cs
│ ├── CurrentProductList.cs
│ ├── Customer.cs
│ ├── CustomerAndSuppliersByCity.cs
│ ├── CustomerDemographic.cs
│ ├── Employee.cs
│ ├── Invoice.cs
│ ├── NorthwindContext.cs
│ ├── Order.cs
│ ├── OrderDetail.cs
│ ├── OrderDetailsExtended.cs
│ ├── OrderSubtotal.cs
│ ├── OrdersQry.cs
│ ├── Product.cs
│ ├── ProductSalesFor1997.cs
│ ├── ProductsAboveAveragePrice.cs
│ ├── ProductsByCategory.cs
│ ├── QuarterlyOrder.cs
│ ├── Region.cs
│ ├── SalesByCategory.cs
│ ├── SalesTotalsByAmount.cs
│ ├── Shipper.cs
│ ├── SummaryOfSalesByQuarter.cs
│ ├── SummaryOfSalesByYear.cs
│ ├── Supplier.cs
│ └── Territory.cs
├── ORM_SQL_İzolasyonu.csproj
├── Program.cs
└── appsettings.json
├── One_to_Many_Relationship
├── Migrations
│ ├── 20220823202226_mig_1.Designer.cs
│ ├── 20220823202226_mig_1.cs
│ └── ESirketDbContextModelSnapshot.cs
├── One_to_Many_Relationship.csproj
└── Program.cs
├── One_to_One_Relationship
├── Migrations
│ ├── 20220820205639_mig_1.Designer.cs
│ ├── 20220820205639_mig_1.cs
│ └── ESirketDbContextModelSnapshot.cs
├── One_to_One_Relationship.csproj
└── Program.cs
├── Owned_Entities_and_Table_Splitting
├── Owned_Entities_and_Table_Splitting.csproj
└── Program.cs
├── Persisting_The_Data
├── Migrations
│ ├── 20220716103730_mig_1.Designer.cs
│ ├── 20220716103730_mig_1.cs
│ └── ETicaretContextModelSnapshot.cs
├── Persisting_The_Data.csproj
└── Program.cs
├── Persisting_The_Data_Delete
├── Persisting_The_Data_Delete.csproj
└── Program.cs
├── Persisting_The_Data_Update
├── Migrations
│ ├── 20220723093252_mig_1.Designer.cs
│ ├── 20220723093252_mig_1.cs
│ └── ETicaretContextModelSnapshot.cs
├── Persisting_The_Data_Update.csproj
└── Program.cs
├── Query_Log
├── Migrations
│ ├── 20221203091028_mig_1.Designer.cs
│ ├── 20221203091028_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
├── Program.cs
└── Query_Log.csproj
├── Query_Tag
├── Program.cs
└── Query_Tags.csproj
├── Querying
├── Find İle Single, SingleOrDefault, First, FirstOrDefault Fonksiyonlarını Karşılaştırma.png
├── Migrations
│ ├── 20220731104123_mig_1.Designer.cs
│ ├── 20220731104123_mig_1.cs
│ ├── 20220731131244_mig_2.Designer.cs
│ ├── 20220731131244_mig_2.cs
│ └── ETicaretContextModelSnapshot.cs
├── Program.cs
├── Querying.csproj
└── Single, SingleOrDefault, First, FirstOrDefault Fonksiyonları Karşılaştırma.png
├── Relationships
├── Program.cs
└── Relationships.csproj
├── Saving_Related_Data
├── Program.cs
└── Saving_Related_Data.csproj
├── Separate_Configuration_Classes
├── Migrations
│ ├── 20220926195526_mig_1.Designer.cs
│ ├── 20220926195526_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
├── Program.cs
└── Separate_Configuration_Classes.csproj
├── Sequences
├── Migrations
│ ├── 20221025180834_mig_1.Designer.cs
│ ├── 20221025180834_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
├── Program.cs
└── Sequences.csproj
├── Shadow_Property
├── Migrations
│ ├── 20220913221407_mig_1.Designer.cs
│ ├── 20220913221407_mig_1.cs
│ ├── 20220913222442_mig_2.Designer.cs
│ ├── 20220913222442_mig_2.cs
│ └── ApplicationDbContextModelSnapshot.cs
├── Program.cs
└── Shadow_Property.csproj
├── Sql_Queries
├── Configurations
│ └── Datas.cs
├── Migrations
│ ├── 20221109163124_mig_1.Designer.cs
│ ├── 20221109163124_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
├── Program.cs
└── Sql_Queries.csproj
├── Stored_Procedures
├── Configurations
│ └── Datas.cs
├── Migrations
│ ├── 20221116153745_mig_1.Designer.cs
│ ├── 20221116153745_mig_1.cs
│ ├── 20221116161124_mig_2.Designer.cs
│ ├── 20221116161124_mig_2.cs
│ ├── 20221116165654_mig_3.Designer.cs
│ ├── 20221116165654_mig_3.cs
│ ├── 20221116173302_mig_4.Designer.cs
│ ├── 20221116173302_mig_4.cs
│ └── ApplicationDbContextModelSnapshot.cs
├── Program.cs
└── Stored_Procedures.csproj
├── Temporal_Tables
├── Migrations
│ ├── 20221209042407_mig_1.Designer.cs
│ ├── 20221209042407_mig_1.cs
│ ├── 20221209042804_mig_2.Designer.cs
│ ├── 20221209042804_mig_2.cs
│ └── ApplicationDbContextModelSnapshot.cs
├── Program.cs
└── Temporal_Tables.csproj
├── Tracking
├── Migrations
│ ├── 20220814114624_mig_1.Designer.cs
│ ├── 20220814114624_mig_1.cs
│ └── ETicaretContextModelSnapshot.cs
├── Program.cs
└── Tracking.csproj
├── Transaction
├── Configurations
│ └── Datas.cs
├── Migrations
│ ├── 20221220155918_mig_1.Designer.cs
│ ├── 20221220155918_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
├── Program.cs
└── Transaction.csproj
├── Updating_Related_Data
├── Migrations
│ ├── 20220831093625_mig_1.Designer.cs
│ ├── 20220831093625_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
├── Program.cs
└── Updating_Related_Data.csproj
├── Value_Conversions
├── Configurations
│ └── Datas.cs
├── Migrations
│ ├── 20221217064335_mig_1.Designer.cs
│ ├── 20221217064335_mig_1.cs
│ └── ApplicationDbContextModelSnapshot.cs
├── Program.cs
└── Value_Conversions.csproj
└── Views
├── Configurations
└── Datas.cs
├── Migrations
├── 20221115160407_mig_1.Designer.cs
├── 20221115160407_mig_1.cs
├── 20221115170952_mig_2.Designer.cs
├── 20221115170952_mig_2.cs
└── ApplicationDbContextModelSnapshot.cs
├── Program.cs
└── Views.csproj
/ChangeTracker/ChangeTracker.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ChangeTracker/Migrations/20220810171938_mig_1.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | #nullable disable
9 |
10 | namespace ChangeTracker.Migrations
11 | {
12 | [DbContext(typeof(ETicaretContext))]
13 | [Migration("20220810171938_mig_1")]
14 | partial class mig_1
15 | {
16 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("ProductVersion", "6.0.8")
21 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
22 |
23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
24 |
25 | modelBuilder.Entity("Urun", b =>
26 | {
27 | b.Property("Id")
28 | .ValueGeneratedOnAdd()
29 | .HasColumnType("int");
30 |
31 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
32 |
33 | b.Property("Fiyat")
34 | .HasColumnType("real");
35 |
36 | b.Property("UrunAdi")
37 | .IsRequired()
38 | .HasColumnType("nvarchar(max)");
39 |
40 | b.HasKey("Id");
41 |
42 | b.ToTable("Urunler");
43 | });
44 | #pragma warning restore 612, 618
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/ChangeTracker/Migrations/20220810171938_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace ChangeTracker.Migrations
6 | {
7 | public partial class mig_1 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.CreateTable(
12 | name: "Urunler",
13 | columns: table => new
14 | {
15 | Id = table.Column(type: "int", nullable: false)
16 | .Annotation("SqlServer:Identity", "1, 1"),
17 | UrunAdi = table.Column(type: "nvarchar(max)", nullable: false),
18 | Fiyat = table.Column(type: "real", nullable: false)
19 | },
20 | constraints: table =>
21 | {
22 | table.PrimaryKey("PK_Urunler", x => x.Id);
23 | });
24 | }
25 |
26 | protected override void Down(MigrationBuilder migrationBuilder)
27 | {
28 | migrationBuilder.DropTable(
29 | name: "Urunler");
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/ChangeTracker/Migrations/ETicaretContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
6 |
7 | #nullable disable
8 |
9 | namespace ChangeTracker.Migrations
10 | {
11 | [DbContext(typeof(ETicaretContext))]
12 | partial class ETicaretContextModelSnapshot : ModelSnapshot
13 | {
14 | protected override void BuildModel(ModelBuilder modelBuilder)
15 | {
16 | #pragma warning disable 612, 618
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "6.0.8")
19 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
20 |
21 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
22 |
23 | modelBuilder.Entity("Urun", b =>
24 | {
25 | b.Property("Id")
26 | .ValueGeneratedOnAdd()
27 | .HasColumnType("int");
28 |
29 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
30 |
31 | b.Property("Fiyat")
32 | .HasColumnType("real");
33 |
34 | b.Property("UrunAdi")
35 | .IsRequired()
36 | .HasColumnType("nvarchar(max)");
37 |
38 | b.HasKey("Id");
39 |
40 | b.ToTable("Urunler");
41 | });
42 | #pragma warning restore 612, 618
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Code_First/Code_First.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Code_First/Migrations/20220620123417_mig_1.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | #nullable disable
9 |
10 | namespace Code_First.Migrations
11 | {
12 | [DbContext(typeof(ECommerceDbContext))]
13 | [Migration("20220620123417_mig_1")]
14 | partial class mig_1
15 | {
16 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("ProductVersion", "6.0.6")
21 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
22 |
23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
24 |
25 | modelBuilder.Entity("Customer", b =>
26 | {
27 | b.Property("Id")
28 | .ValueGeneratedOnAdd()
29 | .HasColumnType("int");
30 |
31 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
32 |
33 | b.Property("FirstName")
34 | .IsRequired()
35 | .HasColumnType("nvarchar(max)");
36 |
37 | b.Property("LastName")
38 | .IsRequired()
39 | .HasColumnType("nvarchar(max)");
40 |
41 | b.HasKey("Id");
42 |
43 | b.ToTable("Customers");
44 | });
45 |
46 | modelBuilder.Entity("Product", b =>
47 | {
48 | b.Property("Id")
49 | .ValueGeneratedOnAdd()
50 | .HasColumnType("int");
51 |
52 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
53 |
54 | b.Property("Name")
55 | .IsRequired()
56 | .HasColumnType("nvarchar(max)");
57 |
58 | b.HasKey("Id");
59 |
60 | b.ToTable("Products");
61 | });
62 | #pragma warning restore 612, 618
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Code_First/Migrations/20220620123417_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Code_First.Migrations
6 | {
7 | public partial class mig_1 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.CreateTable(
12 | name: "Customers",
13 | columns: table => new
14 | {
15 | Id = table.Column(type: "int", nullable: false)
16 | .Annotation("SqlServer:Identity", "1, 1"),
17 | FirstName = table.Column(type: "nvarchar(max)", nullable: false),
18 | LastName = table.Column(type: "nvarchar(max)", nullable: false)
19 | },
20 | constraints: table =>
21 | {
22 | table.PrimaryKey("PK_Customers", x => x.Id);
23 | });
24 |
25 | migrationBuilder.CreateTable(
26 | name: "Products",
27 | columns: table => new
28 | {
29 | Id = table.Column(type: "int", nullable: false)
30 | .Annotation("SqlServer:Identity", "1, 1"),
31 | Name = table.Column(type: "nvarchar(max)", nullable: false)
32 | },
33 | constraints: table =>
34 | {
35 | table.PrimaryKey("PK_Products", x => x.Id);
36 | });
37 | }
38 |
39 | protected override void Down(MigrationBuilder migrationBuilder)
40 | {
41 | migrationBuilder.DropTable(
42 | name: "Customers");
43 |
44 | migrationBuilder.DropTable(
45 | name: "Products");
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Code_First/Migrations/20220620123433_mig_2.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | #nullable disable
9 |
10 | namespace Code_First.Migrations
11 | {
12 | [DbContext(typeof(ECommerceDbContext))]
13 | [Migration("20220620123433_mig_2")]
14 | partial class mig_2
15 | {
16 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("ProductVersion", "6.0.6")
21 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
22 |
23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
24 |
25 | modelBuilder.Entity("Customer", b =>
26 | {
27 | b.Property("Id")
28 | .ValueGeneratedOnAdd()
29 | .HasColumnType("int");
30 |
31 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
32 |
33 | b.Property("FirstName")
34 | .IsRequired()
35 | .HasColumnType("nvarchar(max)");
36 |
37 | b.Property("LastName")
38 | .IsRequired()
39 | .HasColumnType("nvarchar(max)");
40 |
41 | b.HasKey("Id");
42 |
43 | b.ToTable("Customers");
44 | });
45 |
46 | modelBuilder.Entity("Product", b =>
47 | {
48 | b.Property("Id")
49 | .ValueGeneratedOnAdd()
50 | .HasColumnType("int");
51 |
52 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
53 |
54 | b.Property("Name")
55 | .IsRequired()
56 | .HasColumnType("nvarchar(max)");
57 |
58 | b.Property("Price")
59 | .HasColumnType("real");
60 |
61 | b.Property("Quantity")
62 | .HasColumnType("int");
63 |
64 | b.HasKey("Id");
65 |
66 | b.ToTable("Products");
67 | });
68 | #pragma warning restore 612, 618
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Code_First/Migrations/20220620123433_mig_2.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Code_First.Migrations
6 | {
7 | public partial class mig_2 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.AddColumn(
12 | name: "Price",
13 | table: "Products",
14 | type: "real",
15 | nullable: false,
16 | defaultValue: 0f);
17 |
18 | migrationBuilder.AddColumn(
19 | name: "Quantity",
20 | table: "Products",
21 | type: "int",
22 | nullable: false,
23 | defaultValue: 0);
24 | }
25 |
26 | protected override void Down(MigrationBuilder migrationBuilder)
27 | {
28 | migrationBuilder.DropColumn(
29 | name: "Price",
30 | table: "Products");
31 |
32 | migrationBuilder.DropColumn(
33 | name: "Quantity",
34 | table: "Products");
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Code_First/Migrations/20220620123516_mig_3.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | #nullable disable
9 |
10 | namespace Code_First.Migrations
11 | {
12 | [DbContext(typeof(ECommerceDbContext))]
13 | [Migration("20220620123516_mig_3")]
14 | partial class mig_3
15 | {
16 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("ProductVersion", "6.0.6")
21 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
22 |
23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
24 |
25 | modelBuilder.Entity("Customer", b =>
26 | {
27 | b.Property("Id")
28 | .ValueGeneratedOnAdd()
29 | .HasColumnType("int");
30 |
31 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
32 |
33 | b.Property("FirstName")
34 | .IsRequired()
35 | .HasColumnType("nvarchar(max)");
36 |
37 | b.Property("LastName")
38 | .IsRequired()
39 | .HasColumnType("nvarchar(max)");
40 |
41 | b.HasKey("Id");
42 |
43 | b.ToTable("Customers");
44 | });
45 |
46 | modelBuilder.Entity("Product", b =>
47 | {
48 | b.Property("Id")
49 | .ValueGeneratedOnAdd()
50 | .HasColumnType("int");
51 |
52 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
53 |
54 | b.Property("MyProperty")
55 | .HasColumnType("int");
56 |
57 | b.Property("Name")
58 | .IsRequired()
59 | .HasColumnType("nvarchar(max)");
60 |
61 | b.Property("Price")
62 | .HasColumnType("real");
63 |
64 | b.Property("Quantity")
65 | .HasColumnType("int");
66 |
67 | b.HasKey("Id");
68 |
69 | b.ToTable("Products");
70 | });
71 | #pragma warning restore 612, 618
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Code_First/Migrations/20220620123516_mig_3.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Code_First.Migrations
6 | {
7 | public partial class mig_3 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.AddColumn(
12 | name: "MyProperty",
13 | table: "Products",
14 | type: "int",
15 | nullable: false,
16 | defaultValue: 0);
17 | }
18 |
19 | protected override void Down(MigrationBuilder migrationBuilder)
20 | {
21 | migrationBuilder.DropColumn(
22 | name: "MyProperty",
23 | table: "Products");
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Code_First/Migrations/20220620123526_mig_4.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | #nullable disable
9 |
10 | namespace Code_First.Migrations
11 | {
12 | [DbContext(typeof(ECommerceDbContext))]
13 | [Migration("20220620123526_mig_4")]
14 | partial class mig_4
15 | {
16 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("ProductVersion", "6.0.6")
21 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
22 |
23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
24 |
25 | modelBuilder.Entity("Customer", b =>
26 | {
27 | b.Property("Id")
28 | .ValueGeneratedOnAdd()
29 | .HasColumnType("int");
30 |
31 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
32 |
33 | b.Property("FirstName")
34 | .IsRequired()
35 | .HasColumnType("nvarchar(max)");
36 |
37 | b.Property("LastName")
38 | .IsRequired()
39 | .HasColumnType("nvarchar(max)");
40 |
41 | b.HasKey("Id");
42 |
43 | b.ToTable("Customers");
44 | });
45 |
46 | modelBuilder.Entity("Product", b =>
47 | {
48 | b.Property("Id")
49 | .ValueGeneratedOnAdd()
50 | .HasColumnType("int");
51 |
52 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
53 |
54 | b.Property("Name")
55 | .IsRequired()
56 | .HasColumnType("nvarchar(max)");
57 |
58 | b.Property("Price")
59 | .HasColumnType("real");
60 |
61 | b.Property("Quantity")
62 | .HasColumnType("int");
63 |
64 | b.HasKey("Id");
65 |
66 | b.ToTable("Products");
67 | });
68 | #pragma warning restore 612, 618
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Code_First/Migrations/20220620123526_mig_4.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Code_First.Migrations
6 | {
7 | public partial class mig_4 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.DropColumn(
12 | name: "MyProperty",
13 | table: "Products");
14 | }
15 |
16 | protected override void Down(MigrationBuilder migrationBuilder)
17 | {
18 | migrationBuilder.AddColumn(
19 | name: "MyProperty",
20 | table: "Products",
21 | type: "int",
22 | nullable: false,
23 | defaultValue: 0);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Code_First/Migrations/ECommerceDbContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
6 |
7 | #nullable disable
8 |
9 | namespace Code_First.Migrations
10 | {
11 | [DbContext(typeof(ECommerceDbContext))]
12 | partial class ECommerceDbContextModelSnapshot : ModelSnapshot
13 | {
14 | protected override void BuildModel(ModelBuilder modelBuilder)
15 | {
16 | #pragma warning disable 612, 618
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "6.0.6")
19 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
20 |
21 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
22 |
23 | modelBuilder.Entity("Customer", b =>
24 | {
25 | b.Property("Id")
26 | .ValueGeneratedOnAdd()
27 | .HasColumnType("int");
28 |
29 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
30 |
31 | b.Property("FirstName")
32 | .IsRequired()
33 | .HasColumnType("nvarchar(max)");
34 |
35 | b.Property("LastName")
36 | .IsRequired()
37 | .HasColumnType("nvarchar(max)");
38 |
39 | b.HasKey("Id");
40 |
41 | b.ToTable("Customers");
42 | });
43 |
44 | modelBuilder.Entity("Product", b =>
45 | {
46 | b.Property("Id")
47 | .ValueGeneratedOnAdd()
48 | .HasColumnType("int");
49 |
50 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
51 |
52 | b.Property("Name")
53 | .IsRequired()
54 | .HasColumnType("nvarchar(max)");
55 |
56 | b.Property("Price")
57 | .HasColumnType("real");
58 |
59 | b.Property("Quantity")
60 | .HasColumnType("int");
61 |
62 | b.HasKey("Id");
63 |
64 | b.ToTable("Products");
65 | });
66 | #pragma warning restore 612, 618
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Code_First/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 |
3 | ECommerceDbContext context = new();
4 | await context.Database.MigrateAsync();
5 |
6 |
7 | public class ECommerceDbContext : DbContext
8 | {
9 | public DbSet Products { get; set; }
10 | public DbSet Customers { get; set; }
11 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
12 | {
13 | optionsBuilder.UseSqlServer("Server=localhost, 1433;Database=ECommerceDb;User Id=sa;Password=1q2w3e4r+!");
14 | }
15 | }
16 |
17 | //Entity
18 | public class Product
19 | {
20 | public int Id { get; set; }
21 | public string Name { get; set; }
22 | public int Quantity { get; set; }
23 | public float Price { get; set; }
24 | }
25 | //Entity
26 | public class Customer
27 | {
28 | public int Id { get; set; }
29 | public string FirstName { get; set; }
30 | public string LastName { get; set; }
31 | }
--------------------------------------------------------------------------------
/Complex_Relational_Queries/Complex_Relational_Queries.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Connection_Resiliency/Configurations/Datas.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
3 |
4 | namespace Connection_Resiliency.Configurations;
5 |
6 | public class PersonData : IEntityTypeConfiguration
7 | {
8 | public void Configure(EntityTypeBuilder builder)
9 | {
10 | builder.HasData(new Person[]
11 | {
12 | new(){ PersonId = 1, Name = "Ayşe" },
13 | new(){ PersonId = 2, Name = "Hilmi" },
14 | new(){ PersonId = 3, Name = "Raziye" },
15 | new(){ PersonId = 4, Name = "Süleyman" },
16 | new(){ PersonId = 5, Name = "Fadime" },
17 | new(){ PersonId = 6, Name = "Şuayip" },
18 | new(){ PersonId = 7, Name = "Lale" },
19 | new(){ PersonId = 8, Name = "Jale" },
20 | new(){ PersonId = 9, Name = "Rıfkı" },
21 | new(){ PersonId = 10, Name = "Muaviye" },
22 | });
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Connection_Resiliency/Connection_Resiliency.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Connection_Resiliency/Migrations/20221211004253_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
6 |
7 | namespace ConnectionResiliency.Migrations
8 | {
9 | ///
10 | public partial class mig1 : Migration
11 | {
12 | ///
13 | protected override void Up(MigrationBuilder migrationBuilder)
14 | {
15 | migrationBuilder.CreateTable(
16 | name: "Persons",
17 | columns: table => new
18 | {
19 | PersonId = table.Column(type: "int", nullable: false)
20 | .Annotation("SqlServer:Identity", "1, 1"),
21 | Name = table.Column(type: "nvarchar(max)", nullable: false)
22 | },
23 | constraints: table =>
24 | {
25 | table.PrimaryKey("PK_Persons", x => x.PersonId);
26 | });
27 |
28 | migrationBuilder.InsertData(
29 | table: "Persons",
30 | columns: new[] { "PersonId", "Name" },
31 | values: new object[,]
32 | {
33 | { 1, "Ayşe" },
34 | { 2, "Hilmi" },
35 | { 3, "Raziye" },
36 | { 4, "Süleyman" },
37 | { 5, "Fadime" },
38 | { 6, "Şuayip" },
39 | { 7, "Lale" },
40 | { 8, "Jale" },
41 | { 9, "Rıfkı" },
42 | { 10, "Muaviye" }
43 | });
44 | }
45 |
46 | ///
47 | protected override void Down(MigrationBuilder migrationBuilder)
48 | {
49 | migrationBuilder.DropTable(
50 | name: "Persons");
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Connection_Resiliency/Migrations/ApplicationDbContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
6 |
7 | #nullable disable
8 |
9 | namespace ConnectionResiliency.Migrations
10 | {
11 | [DbContext(typeof(ApplicationDbContext))]
12 | partial class ApplicationDbContextModelSnapshot : ModelSnapshot
13 | {
14 | protected override void BuildModel(ModelBuilder modelBuilder)
15 | {
16 | #pragma warning disable 612, 618
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "7.0.0")
19 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
20 |
21 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
22 |
23 | modelBuilder.Entity("Person", b =>
24 | {
25 | b.Property("PersonId")
26 | .ValueGeneratedOnAdd()
27 | .HasColumnType("int");
28 |
29 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("PersonId"));
30 |
31 | b.Property("Name")
32 | .IsRequired()
33 | .HasColumnType("nvarchar(max)");
34 |
35 | b.HasKey("PersonId");
36 |
37 | b.ToTable("Persons");
38 | });
39 | #pragma warning restore 612, 618
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Constraints/Constraints.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Constraints/Migrations/20221018174406_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Constraints.Migrations
6 | {
7 | public partial class mig_1 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.CreateTable(
12 | name: "Blogs",
13 | columns: table => new
14 | {
15 | Id = table.Column(type: "int", nullable: false)
16 | .Annotation("SqlServer:Identity", "1, 1"),
17 | BlogName = table.Column(type: "nvarchar(max)", nullable: false),
18 | Url = table.Column(type: "nvarchar(max)", nullable: false)
19 | },
20 | constraints: table =>
21 | {
22 | table.PrimaryKey("PK_Blogs", x => x.Id);
23 | });
24 |
25 | migrationBuilder.CreateTable(
26 | name: "Posts",
27 | columns: table => new
28 | {
29 | Id = table.Column(type: "int", nullable: false)
30 | .Annotation("SqlServer:Identity", "1, 1"),
31 | Title = table.Column(type: "nvarchar(max)", nullable: false),
32 | BlogUrl = table.Column(type: "nvarchar(max)", nullable: false),
33 | A = table.Column(type: "int", nullable: false),
34 | B = table.Column(type: "int", nullable: false),
35 | BlogId = table.Column(type: "int", nullable: false)
36 | },
37 | constraints: table =>
38 | {
39 | table.PrimaryKey("PK_Posts", x => x.Id);
40 | table.CheckConstraint("a_b_check_const", "[A] > [B]");
41 | table.ForeignKey(
42 | name: "FK_Posts_Blogs_BlogId",
43 | column: x => x.BlogId,
44 | principalTable: "Blogs",
45 | principalColumn: "Id",
46 | onDelete: ReferentialAction.Cascade);
47 | });
48 |
49 | migrationBuilder.CreateIndex(
50 | name: "IX_Posts_BlogId",
51 | table: "Posts",
52 | column: "BlogId");
53 | }
54 |
55 | protected override void Down(MigrationBuilder migrationBuilder)
56 | {
57 | migrationBuilder.DropTable(
58 | name: "Posts");
59 |
60 | migrationBuilder.DropTable(
61 | name: "Blogs");
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Data_Concurrency/Configurations/Datas.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
3 |
4 | namespace Data_Concurrency.Configurations;
5 |
6 | public class PersonData : IEntityTypeConfiguration
7 | {
8 | public void Configure(EntityTypeBuilder builder)
9 | {
10 | builder.HasData(new Person[]
11 | {
12 | new(){ PersonId = 1, Name = "Ayşe" },
13 | new(){ PersonId = 2, Name = "Hilmi" },
14 | new(){ PersonId = 3, Name = "Raziye" },
15 | new(){ PersonId = 4, Name = "Süleyman" },
16 | new(){ PersonId = 5, Name = "Fadime" },
17 | new(){ PersonId = 6, Name = "Şuayip" },
18 | new(){ PersonId = 7, Name = "Lale" },
19 | new(){ PersonId = 8, Name = "Jale" },
20 | new(){ PersonId = 9, Name = "Rıfkı" },
21 | new(){ PersonId = 10, Name = "Muaviye" },
22 | });
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Data_Concurrency/Data_Concurrency.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Data_Concurrency/Migrations/20221215170527_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
6 |
7 | namespace DataConcurrency.Migrations
8 | {
9 | ///
10 | public partial class mig1 : Migration
11 | {
12 | ///
13 | protected override void Up(MigrationBuilder migrationBuilder)
14 | {
15 | migrationBuilder.CreateTable(
16 | name: "Persons",
17 | columns: table => new
18 | {
19 | PersonId = table.Column(type: "int", nullable: false)
20 | .Annotation("SqlServer:Identity", "1, 1"),
21 | Name = table.Column(type: "nvarchar(max)", nullable: false)
22 | },
23 | constraints: table =>
24 | {
25 | table.PrimaryKey("PK_Persons", x => x.PersonId);
26 | });
27 |
28 | migrationBuilder.InsertData(
29 | table: "Persons",
30 | columns: new[] { "PersonId", "Name" },
31 | values: new object[,]
32 | {
33 | { 1, "Ayşe" },
34 | { 2, "Hilmi" },
35 | { 3, "Raziye" },
36 | { 4, "Süleyman" },
37 | { 5, "Fadime" },
38 | { 6, "Şuayip" },
39 | { 7, "Lale" },
40 | { 8, "Jale" },
41 | { 9, "Rıfkı" },
42 | { 10, "Muaviye" }
43 | });
44 | }
45 |
46 | ///
47 | protected override void Down(MigrationBuilder migrationBuilder)
48 | {
49 | migrationBuilder.DropTable(
50 | name: "Persons");
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Data_Concurrency/Migrations/20221215173212_mig_2.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace DataConcurrency.Migrations
6 | {
7 | ///
8 | public partial class mig2 : Migration
9 | {
10 | ///
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.AddColumn(
14 | name: "RowVersion",
15 | table: "Persons",
16 | type: "rowversion",
17 | rowVersion: true,
18 | nullable: false,
19 | defaultValue: new byte[0]);
20 | }
21 |
22 | ///
23 | protected override void Down(MigrationBuilder migrationBuilder)
24 | {
25 | migrationBuilder.DropColumn(
26 | name: "RowVersion",
27 | table: "Persons");
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Data_Seeding/Data_Seeding.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Data_Seeding/Migrations/20220929142854_mig_2.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Data_Seeding.Migrations
6 | {
7 | public partial class mig_2 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.DeleteData(
12 | table: "Blogs",
13 | keyColumn: "Id",
14 | keyValue: 1);
15 |
16 | migrationBuilder.InsertData(
17 | table: "Blogs",
18 | columns: new[] { "Id", "Url" },
19 | values: new object[] { 11, "www.gencayyildiz.com/blog" });
20 | }
21 |
22 | protected override void Down(MigrationBuilder migrationBuilder)
23 | {
24 | migrationBuilder.DeleteData(
25 | table: "Blogs",
26 | keyColumn: "Id",
27 | keyValue: 11);
28 |
29 | migrationBuilder.InsertData(
30 | table: "Blogs",
31 | columns: new[] { "Id", "Url" },
32 | values: new object[] { 1, "www.gencayyildiz.com/blog" });
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Data_Seeding/Migrations/20220929143157_mig_3.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Data_Seeding.Migrations
6 | {
7 | public partial class mig_3 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.DeleteData(
12 | table: "Posts",
13 | keyColumn: "Id",
14 | keyValue: 3);
15 |
16 | migrationBuilder.InsertData(
17 | table: "Posts",
18 | columns: new[] { "Id", "BlogId", "Content", "Title" },
19 | values: new object[] { 5, 2, "...", "B" });
20 | }
21 |
22 | protected override void Down(MigrationBuilder migrationBuilder)
23 | {
24 | migrationBuilder.DeleteData(
25 | table: "Posts",
26 | keyColumn: "Id",
27 | keyValue: 5);
28 |
29 | migrationBuilder.InsertData(
30 | table: "Posts",
31 | columns: new[] { "Id", "BlogId", "Content", "Title" },
32 | values: new object[] { 3, 2, "...", "B" });
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Deleting_Related_Data/Deleting_Related_Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers; buildtransitive
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Deleting_Related_Data/Migrations/20220903164917_mig_2.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Deleting_Related_Data.Migrations
6 | {
7 | public partial class mig_2 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.DropForeignKey(
12 | name: "FK_Posts_Blogs_BlogId",
13 | table: "Posts");
14 |
15 | migrationBuilder.AddForeignKey(
16 | name: "FK_Posts_Blogs_BlogId",
17 | table: "Posts",
18 | column: "BlogId",
19 | principalTable: "Blogs",
20 | principalColumn: "Id",
21 | onDelete: ReferentialAction.Restrict);
22 | }
23 |
24 | protected override void Down(MigrationBuilder migrationBuilder)
25 | {
26 | migrationBuilder.DropForeignKey(
27 | name: "FK_Posts_Blogs_BlogId",
28 | table: "Posts");
29 |
30 | migrationBuilder.AddForeignKey(
31 | name: "FK_Posts_Blogs_BlogId",
32 | table: "Posts",
33 | column: "BlogId",
34 | principalTable: "Blogs",
35 | principalColumn: "Id",
36 | onDelete: ReferentialAction.SetNull);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/EF_Core_7_Bulk_Update_And_Delete/Configurations/Datas.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
3 |
4 | namespace EF_Core_7_Bulk_Update_And_Delete.Configurations;
5 |
6 | public class PersonData : IEntityTypeConfiguration
7 | {
8 | public void Configure(EntityTypeBuilder builder)
9 | {
10 | builder.HasData(new Person[]
11 | {
12 | new(){ PersonId = 1, Name = "Ayşe" },
13 | new(){ PersonId = 2, Name = "Hilmi" },
14 | new(){ PersonId = 3, Name = "Raziye" },
15 | new(){ PersonId = 4, Name = "Süleyman" },
16 | new(){ PersonId = 5, Name = "Fadime" },
17 | new(){ PersonId = 6, Name = "Şuayip" },
18 | new(){ PersonId = 7, Name = "Lale" },
19 | new(){ PersonId = 8, Name = "Jale" },
20 | new(){ PersonId = 9, Name = "Rıfkı" },
21 | new(){ PersonId = 10, Name = "Muaviye" },
22 | });
23 | }
24 | }
--------------------------------------------------------------------------------
/EF_Core_7_Bulk_Update_And_Delete/EF_Core_7_Bulk_Update_And_Delete.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/EF_Core_7_Bulk_Update_And_Delete/Migrations/20221227082615_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
6 |
7 | namespace EFCore7BulkUpdateAndDelete.Migrations
8 | {
9 | ///
10 | public partial class mig1 : Migration
11 | {
12 | ///
13 | protected override void Up(MigrationBuilder migrationBuilder)
14 | {
15 | migrationBuilder.CreateTable(
16 | name: "Persons",
17 | columns: table => new
18 | {
19 | PersonId = table.Column(type: "int", nullable: false)
20 | .Annotation("SqlServer:Identity", "1, 1"),
21 | Name = table.Column(type: "nvarchar(max)", nullable: false)
22 | },
23 | constraints: table =>
24 | {
25 | table.PrimaryKey("PK_Persons", x => x.PersonId);
26 | });
27 |
28 | migrationBuilder.InsertData(
29 | table: "Persons",
30 | columns: new[] { "PersonId", "Name" },
31 | values: new object[,]
32 | {
33 | { 1, "Ayşe" },
34 | { 2, "Hilmi" },
35 | { 3, "Raziye" },
36 | { 4, "Süleyman" },
37 | { 5, "Fadime" },
38 | { 6, "Şuayip" },
39 | { 7, "Lale" },
40 | { 8, "Jale" },
41 | { 9, "Rıfkı" },
42 | { 10, "Muaviye" }
43 | });
44 | }
45 |
46 | ///
47 | protected override void Down(MigrationBuilder migrationBuilder)
48 | {
49 | migrationBuilder.DropTable(
50 | name: "Persons");
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/EF_Core_7_Bulk_Update_And_Delete/Program.cs:
--------------------------------------------------------------------------------
1 |
2 | using Microsoft.EntityFrameworkCore;
3 | using System.Reflection;
4 |
5 | ApplicationDbContext context = new();
6 |
7 | #region EF Core 7 Öncesi Toplu Güncelleme
8 | //var persons = await context.Persons.Where(p => p.PersonId > 5).ToListAsync();
9 | //foreach (var person in persons)
10 | //{
11 | // person.Name = $"{person.Name}...";
12 | //}
13 | //await context.SaveChangesAsync();
14 | #endregion
15 | #region EF Core 7 Öncesi Toplu Silme
16 | //var persons = await context.Persons.Where(p => p.PersonId > 5).ToListAsync();
17 | //context.RemoveRange(persons);
18 | //await context.SaveChangesAsync();
19 | #endregion
20 |
21 |
22 | #region ExecuteUpdate
23 | //await context.Persons.Where(p => p.PersonId > 3).ExecuteUpdateAsync(p => p.SetProperty(p => p.Name, v => v.Name + " yeni"));
24 | //await context.Persons.Where(p => p.PersonId > 3).ExecuteUpdateAsync(p => p.SetProperty(p => p.Name, v => $"{v.Name} yeni"));
25 | #endregion
26 | #region ExecuteDelete
27 | //await context.Persons.Where(p => p.PersonId > 3).ExecuteDeleteAsync();
28 | #endregion
29 |
30 | //ExecuteUpdate ve ExecuteDelete fonksiyonları ile bulk(toplu) veri güncelleme ve silme işlemleri gerçekleştirirken SaveChanges fonksiyonunu çağırmanız gerekmemektedir. Çünkü b fonksiyonlar adları üzerinde Execute... fonksiyonlarıdır. Yani direkt verittaanına fiziksel etkide bulunurlar.
31 |
32 | //Eğer ki istyorsanız transaction kontrolünü ele alarak bu fonksiyonların işlevlerini de süreçte kontrol edebilirsiniz.
33 |
34 | public class Person
35 | {
36 | public int PersonId { get; set; }
37 | public string Name { get; set; }
38 | }
39 | class ApplicationDbContext : DbContext
40 | {
41 | public DbSet Persons { get; set; }
42 | protected override void OnModelCreating(ModelBuilder modelBuilder)
43 | {
44 | modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
45 | }
46 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
47 | {
48 | optionsBuilder
49 | .UseSqlServer("Server=localhost, 1433;Database=ApplicationDB;User ID=SA;Password=1q2w3e4r+!;TrustServerCertificate=True");
50 | }
51 | }
--------------------------------------------------------------------------------
/EF_Core_7_Entity_Splitting/EF_Core_7_Entity_Splitting.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/EF_Core_7_Entity_Splitting/Program.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | using Microsoft.EntityFrameworkCore;
4 |
5 | ApplicationDbContext context = new();
6 |
7 | #region Entity Splitting
8 | //Birden fazla fiziksel tabloyu Entity Framework Core kısmında tek bir entity ile temsil etmemizi sağlayan bir özelliktir.
9 | #endregion
10 | #region Örnek
11 | #region Veri Eklerken
12 | Person person = new()
13 | {
14 | Name = "Nevin",
15 | Surname = "Yıldız",
16 | City = "Ankara",
17 | Country = "Türkiye",
18 | PhoneNumber = "1234567890",
19 | PostCode = "1234567890",
20 | Street = "..."
21 | };
22 |
23 | //await context.Persons.AddAsync(person);
24 | //await context.SaveChangesAsync();
25 | #endregion
26 | #region Veri Okurken
27 | person = await context.Persons.FindAsync(2);
28 | Console.WriteLine();
29 | #endregion
30 | #endregion
31 | public class Person
32 | {
33 | #region Persons Tablosu
34 | public int Id { get; set; }
35 | public string Name { get; set; }
36 | public string Surname { get; set; }
37 |
38 | #endregion
39 | #region PhoneNumbers Tablosu
40 | public string? PhoneNumber { get; set; }
41 | #endregion
42 | #region Addresses Tablosu
43 | public string Street { get; set; }
44 | public string City { get; set; }
45 | public string? PostCode { get; set; }
46 | public string Country { get; set; }
47 | #endregion
48 | }
49 | class ApplicationDbContext : DbContext
50 | {
51 | public DbSet Persons { get; set; }
52 | protected override void OnModelCreating(ModelBuilder modelBuilder)
53 | {
54 | modelBuilder.Entity(entityBuilder =>
55 | {
56 | entityBuilder.ToTable("Persons")
57 | .SplitToTable("PhoneNumbers", tableBuilder =>
58 | {
59 | tableBuilder.Property(person => person.Id).HasColumnName("PersonId");
60 | tableBuilder.Property(person => person.PhoneNumber);
61 | })
62 | .SplitToTable("Addresses", tableBuilder =>
63 | {
64 | tableBuilder.Property(person => person.Id).HasColumnName("PersonId");
65 | tableBuilder.Property(person => person.Street);
66 | tableBuilder.Property(person => person.City);
67 | tableBuilder.Property(person => person.PostCode);
68 | tableBuilder.Property(person => person.Country);
69 | });
70 | });
71 | }
72 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
73 | {
74 | optionsBuilder
75 | .UseSqlServer("Server=localhost, 1433;Database=ApplicationDB;User ID=SA;Password=1q2w3e4r+!;TrustServerCertificate=True");
76 | }
77 | }
--------------------------------------------------------------------------------
/EF_Core_7_Injecting_Services_Into_Entities/Configurations/Datas.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
3 |
4 | namespace EF_Core_7_Injecting_Services_Into_Entities.Configurations;
5 |
6 | public class PersonData : IEntityTypeConfiguration
7 | {
8 | public void Configure(EntityTypeBuilder builder)
9 | {
10 | builder.HasData(new Person[]
11 | {
12 | new(){ PersonId = 1, Name = "Ayşe" },
13 | new(){ PersonId = 2, Name = "Hilmi" },
14 | new(){ PersonId = 3, Name = "Raziye" },
15 | new(){ PersonId = 4, Name = "Süleyman" },
16 | new(){ PersonId = 5, Name = "Fadime" },
17 | new(){ PersonId = 6, Name = "Şuayip" },
18 | new(){ PersonId = 7, Name = "Lale" },
19 | new(){ PersonId = 8, Name = "Jale" },
20 | new(){ PersonId = 9, Name = "Rıfkı" },
21 | new(){ PersonId = 10, Name = "Muaviye" },
22 | });
23 | }
24 | }
--------------------------------------------------------------------------------
/EF_Core_7_Injecting_Services_Into_Entities/EF_Core_7_Injecting_Services_Into_Entities.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/EF_Core_7_Injecting_Services_Into_Entities/Migrations/20221227100013_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
6 |
7 | namespace EFCore7InjectingServicesIntoEntities.Migrations
8 | {
9 | ///
10 | public partial class mig1 : Migration
11 | {
12 | ///
13 | protected override void Up(MigrationBuilder migrationBuilder)
14 | {
15 | migrationBuilder.CreateTable(
16 | name: "Persons",
17 | columns: table => new
18 | {
19 | PersonId = table.Column(type: "int", nullable: false)
20 | .Annotation("SqlServer:Identity", "1, 1"),
21 | Name = table.Column(type: "nvarchar(max)", nullable: false)
22 | },
23 | constraints: table =>
24 | {
25 | table.PrimaryKey("PK_Persons", x => x.PersonId);
26 | });
27 |
28 | migrationBuilder.InsertData(
29 | table: "Persons",
30 | columns: new[] { "PersonId", "Name" },
31 | values: new object[,]
32 | {
33 | { 1, "Ayşe" },
34 | { 2, "Hilmi" },
35 | { 3, "Raziye" },
36 | { 4, "Süleyman" },
37 | { 5, "Fadime" },
38 | { 6, "Şuayip" },
39 | { 7, "Lale" },
40 | { 8, "Jale" },
41 | { 9, "Rıfkı" },
42 | { 10, "Muaviye" }
43 | });
44 | }
45 |
46 | ///
47 | protected override void Down(MigrationBuilder migrationBuilder)
48 | {
49 | migrationBuilder.DropTable(
50 | name: "Persons");
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/EF_Core_7_Injecting_Services_Into_Entities/Program.cs:
--------------------------------------------------------------------------------
1 |
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Diagnostics;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | using Microsoft.Extensions.Logging;
6 | using System.ComponentModel.DataAnnotations.Schema;
7 | using System.Reflection;
8 |
9 | ApplicationDbContext context = new();
10 |
11 | #region Entity'de Service Inject Etme
12 | var persons = await context.Persons.ToListAsync();
13 | foreach (var person in persons)
14 | {
15 | person.ToString();
16 | }
17 | #endregion
18 |
19 | public class PersonServiceInjectionInterceptor : IMaterializationInterceptor
20 | {
21 | public object InitializedInstance(MaterializationInterceptionData materializationData, object instance)
22 | {
23 | if (instance is IHasPersonService hasPersonService)
24 | {
25 | hasPersonService.PersonService = new PersonLogService();
26 | }
27 |
28 | return instance;
29 | }
30 | }
31 | public interface IHasPersonService
32 | {
33 | IPersonLogService PersonService { get; set; }
34 | }
35 | public interface IPersonLogService
36 | {
37 | void LogPerson(string name);
38 | }
39 | public class PersonLogService : IPersonLogService
40 | {
41 | public void LogPerson(string name)
42 | {
43 | Console.WriteLine($"{name} isimli kişi loglanmıştır.");
44 | }
45 | }
46 | public class Person : IHasPersonService
47 | {
48 | public int PersonId { get; set; }
49 | public string Name { get; set; }
50 |
51 | public override string ToString()
52 | {
53 | PersonService?.LogPerson(Name);
54 | return base.ToString();
55 | }
56 |
57 | [NotMapped]
58 | public IPersonLogService? PersonService { get; set; }
59 | }
60 | class ApplicationDbContext : DbContext
61 | {
62 | public DbSet Persons { get; set; }
63 | protected override void OnModelCreating(ModelBuilder modelBuilder)
64 | {
65 | modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
66 | }
67 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
68 | {
69 | optionsBuilder
70 | .UseSqlServer("Server=localhost, 1433;Database=ApplicationDB;User ID=SA;Password=1q2w3e4r+!;TrustServerCertificate=True");
71 |
72 | optionsBuilder.AddInterceptors(new PersonServiceInjectionInterceptor());
73 | }
74 | }
--------------------------------------------------------------------------------
/EF_Core_Configurations/EF_Core_Configurations.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers; buildtransitive
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/EF_Core_Efficient_Querying/EF_Core_Efficient_Querying.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | all
16 | runtime; build; native; contentfiles; analyzers; buildtransitive
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/EF_Core_In_Memory_Database/EF_Core_In_Memory_Database.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | all
16 | runtime; build; native; contentfiles; analyzers; buildtransitive
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/EF_Core_In_Memory_Database/Program.cs:
--------------------------------------------------------------------------------
1 |
2 | using Microsoft.EntityFrameworkCore;
3 | using System.Reflection;
4 | using System;
5 |
6 | ApplicationDbContext context = new();
7 |
8 | //In-Memory database üzerinde çalışırken migration oluşturmaya ve migrate etmeye gerek yoktur!
9 | //In-Memory'de oluşturulmuş olan database uygulama sona erdiği/kapatıldığı taktirde bellekten silinecektir.
10 | //Dolayısıyla özellikle gerçek uygulamalarda in-memory database'i kullanıyorsanız bunun kalıcı değil geçici yani silinebilir bir özellik olduğunu UNUTMAYIN!
11 |
12 | #region EF Core'da In-Memory Database İle Çalışmanın Gereği Nedir?
13 | //Ben deniz(Gençay) genellikle bu özelliği yeni çıkan EF Core özelliklerini test edebilmek için kullanıyorum.
14 | //EF Core, fiziksel veritabanlarından ziyade in-memory'de Database oluşturup üzerinde birçok işlemi yapmamızı sağlayabilmektedir. İşte bu özellik ile gerçek uygulamaların dışında test gibi operasyonları hızlıca yürütebileceğimiz imkanlar elde edebilmekteyiz.
15 | #endregion
16 | #region Avantajları Nelerdir?
17 | //Test ve pre-prod uygulamalarda gerçek/fiziksel veritabanları oluşturmak ve yapılandıormak yerine tüm veritanını bellekte modelleyebilir ve gerekli işlemleri sanki gerçek bir veritabanında çalışıyor gibi orada gerçekleştirebiliriz.
18 | //Bellekte çalışmak geçici bir deneyim olacağı için veritabanı serverlarında test amaçlı üretilmiş olan veritabanlarının lüzumsuz yer işgal etmesini engellemiş olacaktır.
19 | //Bellekte veritabanını modellemek kodun hızlı bir şekilde test edilmesini sağlayacaktır
20 | #endregion
21 | #region Dezavantajları Nelerdir?
22 | //In-Memory'de yapılacak olan veritabanı işlevlerinde ilişkisel modellemeler YAPILAMAMAKTADIR! Bu durumdan dolayı veri tutarlılığı sekteye uğrayabilir ve istatiksel açıdan yanlış sonuçlar elde edilebilir.
23 | #endregion
24 | #region Örnek Çalışma
25 | //Microsoft.EntityFrameworkCore.InMemory kütüphanesi uygulamaya yüklenmelidir.
26 | await context.Persons.AddAsync(new() { Name = "Gençay", Surname = "Yıldız" });
27 | await context.SaveChangesAsync();
28 |
29 | var persons = await context.Persons.ToListAsync();
30 | Console.WriteLine();
31 | #endregion
32 |
33 | class Person
34 | {
35 | public int Id { get; set; }
36 | public string Name { get; set; }
37 | public string Surname { get; set; }
38 | }
39 |
40 | class ApplicationDbContext : DbContext
41 | {
42 | public DbSet Persons { get; set; }
43 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
44 | {
45 | optionsBuilder.UseInMemoryDatabase("exampleDatabase");
46 | }
47 | }
--------------------------------------------------------------------------------
/EF_Core_Logging/EF_Core_Logging.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/EfCoreAdoNet/EfCoreAdoNet.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/EfCoreAdoNet/Migrations/20221129163217_mig_2.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace EfCoreAdoNet.Migrations
6 | {
7 | ///
8 | public partial class mig2 : Migration
9 | {
10 | ///
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 |
14 | }
15 |
16 | ///
17 | protected override void Down(MigrationBuilder migrationBuilder)
18 | {
19 |
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/EfCoreAdoNet/Migrations/20221129163225_mig_3.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace EfCoreAdoNet.Migrations
6 | {
7 | ///
8 | public partial class mig3 : Migration
9 | {
10 | ///
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 |
14 | }
15 |
16 | ///
17 | protected override void Down(MigrationBuilder migrationBuilder)
18 | {
19 |
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/EfCoreAdoNet/Migrations/20221129163228_mig_4.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace EfCoreAdoNet.Migrations
6 | {
7 | ///
8 | public partial class mig4 : Migration
9 | {
10 | ///
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 |
14 | }
15 |
16 | ///
17 | protected override void Down(MigrationBuilder migrationBuilder)
18 | {
19 |
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/EfCoreAdoNet/Migrations/20221129163231_mig_5.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace EfCoreAdoNet.Migrations
6 | {
7 | ///
8 | public partial class mig5 : Migration
9 | {
10 | ///
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 |
14 | }
15 |
16 | ///
17 | protected override void Down(MigrationBuilder migrationBuilder)
18 | {
19 |
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Explicit_Loading/Configurations/Datas.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
3 |
4 | namespace Explicit_Loading.Configurations;
5 | public class EmployeeData : IEntityTypeConfiguration
6 | {
7 | public void Configure(EntityTypeBuilder builder)
8 | {
9 | builder.HasData(new Employee[]
10 | {
11 | new(){ Id = 1, RegionId = 1, Name = "Gençay", Surname = "Yıldız", Salary = 1500},
12 | new(){ Id = 2, RegionId = 2, Name = "Mahmut", Surname = "Yıldız", Salary = 1500},
13 | new(){ Id = 3, RegionId = 1, Name = "Rıfkı", Surname = "Yıldız", Salary = 1500},
14 | new(){ Id = 4, RegionId = 2, Name = "Cüneyt", Surname = "Yıldız", Salary = 1500},
15 | });
16 | }
17 | }
18 | public class OrderData : IEntityTypeConfiguration
19 | {
20 | public void Configure(EntityTypeBuilder builder)
21 | {
22 | builder.HasData(new Order[]
23 | {
24 | new(){ Id = 1, EmployeeId = 1, OrderDate = DateTime.Now },
25 | new(){ Id = 2, EmployeeId = 1, OrderDate = DateTime.Now },
26 | new(){ Id = 3, EmployeeId = 2, OrderDate = DateTime.Now },
27 | new(){ Id = 4, EmployeeId = 2, OrderDate = DateTime.Now },
28 | new(){ Id = 5, EmployeeId = 3, OrderDate = DateTime.Now },
29 | new(){ Id = 6, EmployeeId = 3, OrderDate = DateTime.Now },
30 | new(){ Id = 7, EmployeeId = 3, OrderDate = DateTime.Now },
31 | new(){ Id = 8, EmployeeId = 4, OrderDate = DateTime.Now },
32 | new(){ Id = 9, EmployeeId = 4, OrderDate = DateTime.Now },
33 | new(){ Id = 10, EmployeeId = 1, OrderDate = DateTime.Now },
34 | new(){ Id = 11, EmployeeId = 2, OrderDate = DateTime.Now },
35 | });
36 | }
37 | }
38 | public class RegionData : IEntityTypeConfiguration
39 | {
40 | public void Configure(EntityTypeBuilder builder)
41 | {
42 | builder.HasData(new Region[]
43 | {
44 | new(){ Id = 1, Name = "Ankara" },
45 | new(){ Id = 2, Name = "Yozgat" }
46 | });
47 | }
48 | }
--------------------------------------------------------------------------------
/Explicit_Loading/Explicit_Loading.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Functions/Functions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Functions/Migrations/20221122230105_mig_2.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Functions.Migrations
6 | {
7 | ///
8 | public partial class mig2 : Migration
9 | {
10 | ///
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.Sql($@"
14 | CREATE FUNCTION getPersonTotalOrderPrice(@personId INT)
15 | RETURNS INT
16 | AS
17 | BEGIN
18 | DECLARE @totalPrice INT
19 | SELECT @totalPrice = SUM(o.Price) FROM Persons p
20 | JOIN Orders o
21 | ON p.PersonId = o.PersonId
22 | WHERE p.PersonId = @personId
23 | RETURN @totalPrice
24 | END
25 | ");
26 | }
27 |
28 | ///
29 | protected override void Down(MigrationBuilder migrationBuilder)
30 | {
31 | migrationBuilder.Sql($@"DROP FUNCTION getPersonTotalOrderPrice");
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Functions/Migrations/20221122234402_mig_3.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Functions.Migrations
6 | {
7 | ///
8 | public partial class mig3 : Migration
9 | {
10 | ///
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.Sql($@"
14 | CREATE FUNCTION bestSellingStaff(@totalOrderPrice INT = 10000)
15 | RETURNS TABLE
16 | AS
17 | RETURN
18 | SELECT TOP 1 p.Name, COUNT(*) OrderCount, SUM(o.Price) TotalOrderPrice FROM Persons p
19 | JOIN Orders o
20 | ON p.PersonId = o.PersonId
21 | GROUP By p.Name
22 | HAVING SUM(o.Price) < @totalOrderPrice
23 | ORDER By OrderCount DESC
24 | ");
25 | }
26 |
27 | ///
28 | protected override void Down(MigrationBuilder migrationBuilder)
29 | {
30 | migrationBuilder.Sql($@"DROP FUNCTION bestSellingStaff");
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Generated_Values/Generated_Values.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Generated_Values/Migrations/20220924160329_mig_1.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | using Microsoft.EntityFrameworkCore.Metadata;
6 | using Microsoft.EntityFrameworkCore.Migrations;
7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
8 |
9 | #nullable disable
10 |
11 | namespace Generated_Values.Migrations
12 | {
13 | [DbContext(typeof(ApplicationDbContext))]
14 | [Migration("20220924160329_mig_1")]
15 | partial class mig_1
16 | {
17 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
18 | {
19 | #pragma warning disable 612, 618
20 | modelBuilder
21 | .HasAnnotation("ProductVersion", "6.0.9")
22 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
23 |
24 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
25 |
26 | modelBuilder.Entity("Person", b =>
27 | {
28 | b.Property("PersonId")
29 | .HasColumnType("int");
30 |
31 | b.Property("Name")
32 | .IsRequired()
33 | .HasColumnType("nvarchar(max)");
34 |
35 | b.Property("PersonCode")
36 | .ValueGeneratedOnAdd()
37 | .HasColumnType("uniqueidentifier")
38 | .HasDefaultValueSql("NEWID()");
39 |
40 | b.Property("Premium")
41 | .HasColumnType("int");
42 |
43 | b.Property("Salary")
44 | .ValueGeneratedOnAdd()
45 | .HasColumnType("int")
46 | .HasDefaultValueSql("FLOOR(RAND() * 1000)");
47 |
48 | b.Property("Surname")
49 | .IsRequired()
50 | .HasColumnType("nvarchar(max)");
51 |
52 | b.Property("TotalGain")
53 | .ValueGeneratedOnAddOrUpdate()
54 | .HasColumnType("int")
55 | .HasComputedColumnSql("([Salary] + [Premium]) * 10");
56 |
57 | b.HasKey("PersonId");
58 |
59 | b.ToTable("Persons");
60 | });
61 | #pragma warning restore 612, 618
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Generated_Values/Migrations/20220924160329_mig_1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore.Migrations;
3 |
4 | #nullable disable
5 |
6 | namespace Generated_Values.Migrations
7 | {
8 | public partial class mig_1 : Migration
9 | {
10 | protected override void Up(MigrationBuilder migrationBuilder)
11 | {
12 | migrationBuilder.CreateTable(
13 | name: "Persons",
14 | columns: table => new
15 | {
16 | PersonId = table.Column(type: "int", nullable: false),
17 | Name = table.Column(type: "nvarchar(max)", nullable: false),
18 | Surname = table.Column(type: "nvarchar(max)", nullable: false),
19 | Premium = table.Column(type: "int", nullable: false),
20 | Salary = table.Column(type: "int", nullable: false, defaultValueSql: "FLOOR(RAND() * 1000)"),
21 | TotalGain = table.Column(type: "int", nullable: false, computedColumnSql: "([Salary] + [Premium]) * 10"),
22 | PersonCode = table.Column(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()")
23 | },
24 | constraints: table =>
25 | {
26 | table.PrimaryKey("PK_Persons", x => x.PersonId);
27 | });
28 | }
29 |
30 | protected override void Down(MigrationBuilder migrationBuilder)
31 | {
32 | migrationBuilder.DropTable(
33 | name: "Persons");
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Generated_Values/Migrations/20220924161111_mig_2.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | using Microsoft.EntityFrameworkCore.Metadata;
6 | using Microsoft.EntityFrameworkCore.Migrations;
7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
8 |
9 | #nullable disable
10 |
11 | namespace Generated_Values.Migrations
12 | {
13 | [DbContext(typeof(ApplicationDbContext))]
14 | [Migration("20220924161111_mig_2")]
15 | partial class mig_2
16 | {
17 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
18 | {
19 | #pragma warning disable 612, 618
20 | modelBuilder
21 | .HasAnnotation("ProductVersion", "6.0.9")
22 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
23 |
24 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
25 |
26 | modelBuilder.Entity("Person", b =>
27 | {
28 | b.Property("PersonId")
29 | .HasColumnType("int");
30 |
31 | b.Property("Name")
32 | .IsRequired()
33 | .HasColumnType("nvarchar(max)");
34 |
35 | b.Property("PersonCode")
36 | .ValueGeneratedOnAdd()
37 | .HasColumnType("uniqueidentifier")
38 | .HasDefaultValueSql("NEWID()");
39 |
40 | b.Property("Premium")
41 | .HasColumnType("int");
42 |
43 | b.Property("Salary")
44 | .ValueGeneratedOnAdd()
45 | .HasColumnType("int")
46 | .HasDefaultValueSql("FLOOR(RAND() * 1000)");
47 |
48 | b.Property("Surname")
49 | .IsRequired()
50 | .HasColumnType("nvarchar(max)");
51 |
52 | b.Property("TotalGain")
53 | .ValueGeneratedOnAddOrUpdate()
54 | .HasColumnType("int")
55 | .HasComputedColumnSql("([Salary] + [Premium]) * 10");
56 |
57 | b.HasKey("PersonId");
58 |
59 | b.ToTable("Persons");
60 | });
61 | #pragma warning restore 612, 618
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Generated_Values/Migrations/20220924161111_mig_2.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Generated_Values.Migrations
6 | {
7 | public partial class mig_2 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 |
12 | }
13 |
14 | protected override void Down(MigrationBuilder migrationBuilder)
15 | {
16 |
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Generated_Values/Migrations/ApplicationDbContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | using Microsoft.EntityFrameworkCore.Metadata;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | #nullable disable
9 |
10 | namespace Generated_Values.Migrations
11 | {
12 | [DbContext(typeof(ApplicationDbContext))]
13 | partial class ApplicationDbContextModelSnapshot : ModelSnapshot
14 | {
15 | protected override void BuildModel(ModelBuilder modelBuilder)
16 | {
17 | #pragma warning disable 612, 618
18 | modelBuilder
19 | .HasAnnotation("ProductVersion", "6.0.9")
20 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
21 |
22 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
23 |
24 | modelBuilder.Entity("Person", b =>
25 | {
26 | b.Property("PersonId")
27 | .HasColumnType("int");
28 |
29 | b.Property("Name")
30 | .IsRequired()
31 | .HasColumnType("nvarchar(max)");
32 |
33 | b.Property("PersonCode")
34 | .ValueGeneratedOnAdd()
35 | .HasColumnType("uniqueidentifier")
36 | .HasDefaultValueSql("NEWID()");
37 |
38 | b.Property("Premium")
39 | .HasColumnType("int");
40 |
41 | b.Property("Salary")
42 | .ValueGeneratedOnAdd()
43 | .HasColumnType("int")
44 | .HasDefaultValueSql("FLOOR(RAND() * 1000)");
45 |
46 | b.Property("Surname")
47 | .IsRequired()
48 | .HasColumnType("nvarchar(max)");
49 |
50 | b.Property("TotalGain")
51 | .ValueGeneratedOnAddOrUpdate()
52 | .HasColumnType("int")
53 | .HasComputedColumnSql("([Salary] + [Premium]) * 10");
54 |
55 | b.HasKey("PersonId");
56 |
57 | b.ToTable("Persons");
58 | });
59 | #pragma warning restore 612, 618
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Global_Query_Filters/Global_Query_Filters.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Indexes/Indexes - Backup.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Indexes/Indexes.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Indexes/Migrations/20221024204508_mig_1.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | #nullable disable
9 |
10 | namespace Indexes.Migrations
11 | {
12 | [DbContext(typeof(ApplicationDbContext))]
13 | [Migration("20221024204508_mig_1")]
14 | partial class mig1
15 | {
16 | ///
17 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
18 | {
19 | #pragma warning disable 612, 618
20 | modelBuilder
21 | .HasAnnotation("ProductVersion", "7.0.0-rc.2.22472.11")
22 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
23 |
24 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
25 |
26 | modelBuilder.Entity("Employee", b =>
27 | {
28 | b.Property("Id")
29 | .ValueGeneratedOnAdd()
30 | .HasColumnType("int");
31 |
32 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
33 |
34 | b.Property("Name")
35 | .HasColumnType("nvarchar(450)");
36 |
37 | b.Property("Salary")
38 | .HasColumnType("int");
39 |
40 | b.Property("Surname")
41 | .HasColumnType("nvarchar(max)");
42 |
43 | b.HasKey("Id");
44 |
45 | b.HasIndex("Name")
46 | .HasFilter("[NAME] IS NOT NULL");
47 |
48 | b.ToTable("Employees");
49 | });
50 | #pragma warning restore 612, 618
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Indexes/Migrations/20221024204508_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Indexes.Migrations
6 | {
7 | ///
8 | public partial class mig1 : Migration
9 | {
10 | ///
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.CreateTable(
14 | name: "Employees",
15 | columns: table => new
16 | {
17 | Id = table.Column(type: "int", nullable: false)
18 | .Annotation("SqlServer:Identity", "1, 1"),
19 | Name = table.Column(type: "nvarchar(450)", nullable: true),
20 | Surname = table.Column(type: "nvarchar(max)", nullable: true),
21 | Salary = table.Column(type: "int", nullable: false)
22 | },
23 | constraints: table =>
24 | {
25 | table.PrimaryKey("PK_Employees", x => x.Id);
26 | });
27 |
28 | migrationBuilder.CreateIndex(
29 | name: "IX_Employees_Name",
30 | table: "Employees",
31 | column: "Name",
32 | filter: "[NAME] IS NOT NULL");
33 | }
34 |
35 | ///
36 | protected override void Down(MigrationBuilder migrationBuilder)
37 | {
38 | migrationBuilder.DropTable(
39 | name: "Employees");
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Indexes/Migrations/ApplicationDbContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
6 |
7 | #nullable disable
8 |
9 | namespace Indexes.Migrations
10 | {
11 | [DbContext(typeof(ApplicationDbContext))]
12 | partial class ApplicationDbContextModelSnapshot : ModelSnapshot
13 | {
14 | protected override void BuildModel(ModelBuilder modelBuilder)
15 | {
16 | #pragma warning disable 612, 618
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "7.0.0-rc.2.22472.11")
19 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
20 |
21 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
22 |
23 | modelBuilder.Entity("Employee", b =>
24 | {
25 | b.Property("Id")
26 | .ValueGeneratedOnAdd()
27 | .HasColumnType("int");
28 |
29 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
30 |
31 | b.Property("Name")
32 | .HasColumnType("nvarchar(450)");
33 |
34 | b.Property("Salary")
35 | .HasColumnType("int");
36 |
37 | b.Property("Surname")
38 | .HasColumnType("nvarchar(max)");
39 |
40 | b.HasKey("Id");
41 |
42 | b.HasIndex("Name")
43 | .HasFilter("[NAME] IS NOT NULL");
44 |
45 | b.ToTable("Employees");
46 | });
47 | #pragma warning restore 612, 618
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Inheritance_Table_Per_Concrete_Type/Inheritance_Table_Per_Concrete_Type.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | runtime; build; native; contentfiles; analyzers; buildtransitive
15 | all
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Inheritance_Table_Per_Hierarchy/Inheritance_Table_Per_Hierarchy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Inheritance_Table_Per_Hierarchy/Migrations/20221005183014_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Inheritance_Table_Per_Hierarchy.Migrations
6 | {
7 | public partial class mig_1 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.CreateTable(
12 | name: "Persons",
13 | columns: table => new
14 | {
15 | Id = table.Column(type: "int", nullable: false)
16 | .Annotation("SqlServer:Identity", "1, 1"),
17 | Name = table.Column(type: "nvarchar(max)", nullable: true),
18 | Surname = table.Column(type: "nvarchar(max)", nullable: true),
19 | Discriminator = table.Column(type: "nvarchar(max)", nullable: false),
20 | A = table.Column(type: "int", nullable: true),
21 | CompanyName = table.Column(type: "nvarchar(max)", nullable: true),
22 | Department = table.Column(type: "nvarchar(max)", nullable: true),
23 | Technician_A = table.Column(type: "int", nullable: true),
24 | Branch = table.Column(type: "nvarchar(max)", nullable: true)
25 | },
26 | constraints: table =>
27 | {
28 | table.PrimaryKey("PK_Persons", x => x.Id);
29 | });
30 | }
31 |
32 | protected override void Down(MigrationBuilder migrationBuilder)
33 | {
34 | migrationBuilder.DropTable(
35 | name: "Persons");
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Inheritance_Table_Per_Type/Inheritance_Table_Per_Type.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Keyless_Entity_Types/Keyless_Entity_Types.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Keyless_Entity_Types/Migrations/20221130171307_mig_2.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace KeylessEntityTypes.Migrations
6 | {
7 | ///
8 | public partial class mig2 : Migration
9 | {
10 | ///
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.Sql($@"
14 | CREATE VIEW vw_PersonOrderCount
15 | AS
16 | SELECT p.Name, COUNT(*) Count FROM Persons p
17 | JOIN Orders o
18 | ON p.PersonId = o.PersonId
19 | GROUP By p.Name
20 | ");
21 | }
22 |
23 | ///
24 | protected override void Down(MigrationBuilder migrationBuilder)
25 | {
26 | migrationBuilder.Sql($@"DROP VIEW vw_PersonOrderCount");
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Keyless_Entity_Types/Migrations/20221130171902_mig_3.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace KeylessEntityTypes.Migrations
6 | {
7 | ///
8 | public partial class mig3 : Migration
9 | {
10 | ///
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 |
14 | }
15 |
16 | ///
17 | protected override void Down(MigrationBuilder migrationBuilder)
18 | {
19 |
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Lazy_Loading/Configurations/Datas.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
3 |
4 | namespace Lazy_Loading.Configurations;
5 | public class EmployeeData : IEntityTypeConfiguration
6 | {
7 | public void Configure(EntityTypeBuilder builder)
8 | {
9 | builder.HasData(new Employee[]
10 | {
11 | new(){ Id = 1, RegionId = 1, Name = "Gençay", Surname = "Yıldız", Salary = 1500},
12 | new(){ Id = 2, RegionId = 2, Name = "Mahmut", Surname = "Yıldız", Salary = 1500},
13 | new(){ Id = 3, RegionId = 1, Name = "Rıfkı", Surname = "Yıldız", Salary = 1500},
14 | new(){ Id = 4, RegionId = 2, Name = "Cüneyt", Surname = "Yıldız", Salary = 1500},
15 | });
16 | }
17 | }
18 | public class OrderData : IEntityTypeConfiguration
19 | {
20 | public void Configure(EntityTypeBuilder builder)
21 | {
22 | builder.HasData(new Order[]
23 | {
24 | new(){ Id = 1, EmployeeId = 1, OrderDate = DateTime.Now },
25 | new(){ Id = 2, EmployeeId = 1, OrderDate = DateTime.Now },
26 | new(){ Id = 3, EmployeeId = 2, OrderDate = DateTime.Now },
27 | new(){ Id = 4, EmployeeId = 2, OrderDate = DateTime.Now },
28 | new(){ Id = 5, EmployeeId = 3, OrderDate = DateTime.Now },
29 | new(){ Id = 6, EmployeeId = 3, OrderDate = DateTime.Now },
30 | new(){ Id = 7, EmployeeId = 3, OrderDate = DateTime.Now },
31 | new(){ Id = 8, EmployeeId = 4, OrderDate = DateTime.Now },
32 | new(){ Id = 9, EmployeeId = 4, OrderDate = DateTime.Now },
33 | new(){ Id = 10, EmployeeId = 1, OrderDate = DateTime.Now },
34 | new(){ Id = 11, EmployeeId = 2, OrderDate = DateTime.Now },
35 | });
36 | }
37 | }
38 | public class RegionData : IEntityTypeConfiguration
39 | {
40 | public void Configure(EntityTypeBuilder builder)
41 | {
42 | builder.HasData(new Region[]
43 | {
44 | new(){ Id = 1, Name = "Ankara" },
45 | new(){ Id = 2, Name = "Yozgat" }
46 | });
47 | }
48 | }
--------------------------------------------------------------------------------
/Lazy_Loading/Lazy_Loading.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | all
17 | runtime; build; native; contentfiles; analyzers; buildtransitive
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Lesson1/Lesson1.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | Always
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Lesson1/ORM.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.Extensions.Configuration;
3 |
4 | namespace Lesson1
5 | {
6 | public class NorthwindDbContext : DbContext
7 | {
8 | public DbSet Employees { get; set; }
9 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
10 | {
11 | ConfigurationManager configuration = new();
12 | configuration.AddJsonFile("appsettings.json");
13 | optionsBuilder.UseSqlServer($"Server=localhost, 1433;Database=Northwind;User Id=sa;Password={configuration["Password"]}");
14 | }
15 | }
16 | public class Employee
17 | {
18 | public int EmployeeID { get; set; }
19 | public string LastName { get; set; }
20 | public string FirstName { get; set; }
21 | public string? Title { get; set; }
22 | public string? TitleOfCourtesy { get; set; }
23 | public DateTime? BirthDate { get; set; }
24 | public DateTime? HireDate { get; set; }
25 | public string? Address { get; set; }
26 | public string? City { get; set; }
27 | public string? PostalCode { get; set; }
28 | public string? Country { get; set; }
29 | public string? HomePhone { get; set; }
30 | public string? Extension { get; set; }
31 | public string? Notes { get; set; }
32 | public int? ReportsTo { get; set; }
33 | public string? PhotoPath { get; set; }
34 | public string? Region { get; set; }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Lesson1/Program.cs:
--------------------------------------------------------------------------------
1 | using Lesson1;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.Extensions.Configuration;
4 | using System.Data.SqlClient;
5 |
6 |
7 | #region Kod İçinde SQL
8 | ConfigurationManager configuration = new();
9 | configuration.AddJsonFile("appsettings.json");
10 |
11 | await using SqlConnection connection = new($"Server=localhost, 1433;Database=Northwind;User Id=sa;Password={configuration["Password"]}");
12 | await connection.OpenAsync();
13 |
14 | SqlCommand command = new("Select * from Employees", connection);
15 | SqlDataReader dr = await command.ExecuteReaderAsync();
16 | while (await dr.ReadAsync())
17 | {
18 | Console.WriteLine($"{dr["FirstName"]} {dr["LastName"]}");
19 | }
20 | await connection.CloseAsync();
21 | #endregion
22 |
23 | #region ORM
24 | NorthwindDbContext context = new();
25 | var employeeDatas = await context.Employees.ToListAsync();
26 |
27 | #endregion
28 |
29 | //ORM'in kullanılmadığı durumlarda nasıl bir yaklaşım sergilenir?
30 | //ORM'li ve ORM'siz kod mukayesesi
31 | //İlişkisel eşleştirme nedir?
32 | //SQL'den arındırılmış kod!
33 | //Neden ORM kullanmalıyız?
--------------------------------------------------------------------------------
/Lesson1/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Password": "***"
3 | }
--------------------------------------------------------------------------------
/Lesson9/Lesson9.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Lesson9/Migrations/20220704202121_mig_1.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | #nullable disable
9 |
10 | namespace Lesson9.Migrations
11 | {
12 | [DbContext(typeof(ETicaretContext))]
13 | [Migration("20220704202121_mig_1")]
14 | partial class mig_1
15 | {
16 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("ProductVersion", "6.0.5")
21 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
22 |
23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
24 |
25 | modelBuilder.Entity("Urun", b =>
26 | {
27 | b.Property("UrunID")
28 | .ValueGeneratedOnAdd()
29 | .HasColumnType("int");
30 |
31 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("UrunID"), 1L, 1);
32 |
33 | b.HasKey("UrunID");
34 |
35 | b.ToTable("Urunler");
36 | });
37 | #pragma warning restore 612, 618
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Lesson9/Migrations/20220704202121_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Lesson9.Migrations
6 | {
7 | public partial class mig_1 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.CreateTable(
12 | name: "Urunler",
13 | columns: table => new
14 | {
15 | UrunID = table.Column(type: "int", nullable: false)
16 | .Annotation("SqlServer:Identity", "1, 1")
17 | },
18 | constraints: table =>
19 | {
20 | table.PrimaryKey("PK_Urunler", x => x.UrunID);
21 | });
22 | }
23 |
24 | protected override void Down(MigrationBuilder migrationBuilder)
25 | {
26 | migrationBuilder.DropTable(
27 | name: "Urunler");
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Lesson9/Migrations/ETicaretContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
6 |
7 | #nullable disable
8 |
9 | namespace Lesson9.Migrations
10 | {
11 | [DbContext(typeof(ETicaretContext))]
12 | partial class ETicaretContextModelSnapshot : ModelSnapshot
13 | {
14 | protected override void BuildModel(ModelBuilder modelBuilder)
15 | {
16 | #pragma warning disable 612, 618
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "6.0.5")
19 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
20 |
21 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
22 |
23 | modelBuilder.Entity("Urun", b =>
24 | {
25 | b.Property("UrunID")
26 | .ValueGeneratedOnAdd()
27 | .HasColumnType("int");
28 |
29 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("UrunID"), 1L, 1);
30 |
31 | b.HasKey("UrunID");
32 |
33 | b.ToTable("Urunler");
34 | });
35 | #pragma warning restore 612, 618
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Lesson9/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 |
3 | Console.WriteLine();
4 | public class ETicaretContext : DbContext
5 | {
6 | public DbSet Urunler { get; set; }
7 |
8 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
9 | {
10 | optionsBuilder.UseSqlServer("Server=localhost, 1433;Database=ETicaretDB;User ID=SA;Password=1q2w3e4r+!");
11 | //Provider
12 | //ConnectionString
13 | //Lazy Loading
14 | //vb.
15 | }
16 | }
17 | public class Urun
18 | {
19 | //public int Id { get; set; }
20 | //public int ID { get; set; }
21 | //public int UrunId { get; set; }
22 | public int UrunID { get; set; }
23 | }
24 |
25 | #region OnConfiguring İle Konfigürasyon Ayarlarını Gerçekleştirmek
26 | //EF Core tool'unu yapılandırmak için kullandığımız bir metottur.
27 | //Context nesnesinde override edilerek kullanılmaktadır.
28 | #endregion
29 | #region Basit Düzeyde Entity Tanımlama Kuralları
30 | //EF Core, her tablonun default olarak bir primary key kolonu olması gerektiğini kabul eder!
31 | //Haliyle, bu kolonu temsil eden bir property tanımlamadığımız taktirde hata verecektir!
32 | #endregion
33 | #region Tablo Adını Belirleme
34 |
35 | #endregion
--------------------------------------------------------------------------------
/Loading_Related_Data/Configurations/Datas.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore.Metadata.Builders;
3 |
4 | namespace Loading_Related_Data.Configurations;
5 | public class EmployeeData : IEntityTypeConfiguration
6 | {
7 | public void Configure(EntityTypeBuilder builder)
8 | {
9 | builder.HasData(new Employee[]
10 | {
11 | new(){ Id = 1, RegionId = 1, Name = "Gençay", Surname = "Yıldız", Salary = 1500},
12 | new(){ Id = 2, RegionId = 2, Name = "Mahmut", Surname = "Yıldız", Salary = 1500},
13 | new(){ Id = 3, RegionId = 1, Name = "Rıfkı", Surname = "Yıldız", Salary = 1500},
14 | new(){ Id = 4, RegionId = 2, Name = "Cüneyt", Surname = "Yıldız", Salary = 1500},
15 | });
16 | }
17 | }
18 | public class OrderData : IEntityTypeConfiguration
19 | {
20 | public void Configure(EntityTypeBuilder builder)
21 | {
22 | builder.HasData(new Order[]
23 | {
24 | new(){ Id = 1, EmployeeId = 1, OrderDate = DateTime.Now },
25 | new(){ Id = 2, EmployeeId = 1, OrderDate = DateTime.Now },
26 | new(){ Id = 3, EmployeeId = 2, OrderDate = DateTime.Now },
27 | new(){ Id = 4, EmployeeId = 2, OrderDate = DateTime.Now },
28 | new(){ Id = 5, EmployeeId = 3, OrderDate = DateTime.Now },
29 | new(){ Id = 6, EmployeeId = 3, OrderDate = DateTime.Now },
30 | new(){ Id = 7, EmployeeId = 3, OrderDate = DateTime.Now },
31 | new(){ Id = 8, EmployeeId = 4, OrderDate = DateTime.Now },
32 | new(){ Id = 9, EmployeeId = 4, OrderDate = DateTime.Now },
33 | new(){ Id = 10, EmployeeId = 1, OrderDate = DateTime.Now },
34 | new(){ Id = 11, EmployeeId = 2, OrderDate = DateTime.Now },
35 | });
36 | }
37 | }
38 | public class RegionData : IEntityTypeConfiguration
39 | {
40 | public void Configure(EntityTypeBuilder builder)
41 | {
42 | builder.HasData(new Region[]
43 | {
44 | new(){ Id = 1, Name = "Ankara" },
45 | new(){ Id = 2, Name = "Yozgat" }
46 | });
47 | }
48 | }
--------------------------------------------------------------------------------
/Loading_Related_Data/Loading_Related_Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Many_to_Many_Relationship/Many_to_Many_Relationship.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers; buildtransitive
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/AlphabeticalListOfProduct.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class AlphabeticalListOfProduct
7 | {
8 | public int ProductId { get; set; }
9 | public string ProductName { get; set; } = null!;
10 | public int? SupplierId { get; set; }
11 | public int? CategoryId { get; set; }
12 | public string? QuantityPerUnit { get; set; }
13 | public decimal? UnitPrice { get; set; }
14 | public short? UnitsInStock { get; set; }
15 | public short? UnitsOnOrder { get; set; }
16 | public short? ReorderLevel { get; set; }
17 | public bool Discontinued { get; set; }
18 | public string CategoryName { get; set; } = null!;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/Category.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class Category
7 | {
8 | public Category()
9 | {
10 | Products = new HashSet();
11 | }
12 |
13 | public int CategoryId { get; set; }
14 | public string CategoryName { get; set; } = null!;
15 | public string? Description { get; set; }
16 | public byte[]? Picture { get; set; }
17 |
18 | public virtual ICollection Products { get; set; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/CategorySalesFor1997.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class CategorySalesFor1997
7 | {
8 | public string CategoryName { get; set; } = null!;
9 | public decimal? CategorySales { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/CurrentProductList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class CurrentProductList
7 | {
8 | public int ProductId { get; set; }
9 | public string ProductName { get; set; } = null!;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/Customer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class Customer
7 | {
8 | public Customer()
9 | {
10 | Orders = new HashSet();
11 | CustomerTypes = new HashSet();
12 | }
13 |
14 | public string CustomerId { get; set; } = null!;
15 | public string CompanyName { get; set; } = null!;
16 | public string? ContactName { get; set; }
17 | public string? ContactTitle { get; set; }
18 | public string? Address { get; set; }
19 | public string? City { get; set; }
20 | public string? Region { get; set; }
21 | public string? PostalCode { get; set; }
22 | public string? Country { get; set; }
23 | public string? Phone { get; set; }
24 | public string? Fax { get; set; }
25 |
26 | public virtual ICollection Orders { get; set; }
27 |
28 | public virtual ICollection CustomerTypes { get; set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/CustomerAndSuppliersByCity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class CustomerAndSuppliersByCity
7 | {
8 | public string? City { get; set; }
9 | public string CompanyName { get; set; } = null!;
10 | public string? ContactName { get; set; }
11 | public string Relationship { get; set; } = null!;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/CustomerDemographic.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class CustomerDemographic
7 | {
8 | public CustomerDemographic()
9 | {
10 | Customers = new HashSet();
11 | }
12 |
13 | public string CustomerTypeId { get; set; } = null!;
14 | public string? CustomerDesc { get; set; }
15 |
16 | public virtual ICollection Customers { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/Employee.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class Employee
7 | {
8 | public Employee()
9 | {
10 | InverseReportsToNavigation = new HashSet();
11 | Orders = new HashSet();
12 | Territories = new HashSet();
13 | }
14 |
15 | public int EmployeeId { get; set; }
16 | public string LastName { get; set; } = null!;
17 | public string FirstName { get; set; } = null!;
18 | public string? Title { get; set; }
19 | public string? TitleOfCourtesy { get; set; }
20 | public DateTime? BirthDate { get; set; }
21 | public DateTime? HireDate { get; set; }
22 | public string? Address { get; set; }
23 | public string? City { get; set; }
24 | public string? Region { get; set; }
25 | public string? PostalCode { get; set; }
26 | public string? Country { get; set; }
27 | public string? HomePhone { get; set; }
28 | public string? Extension { get; set; }
29 | public byte[]? Photo { get; set; }
30 | public string? Notes { get; set; }
31 | public int? ReportsTo { get; set; }
32 | public string? PhotoPath { get; set; }
33 |
34 | public virtual Employee? ReportsToNavigation { get; set; }
35 | public virtual ICollection InverseReportsToNavigation { get; set; }
36 | public virtual ICollection Orders { get; set; }
37 |
38 | public virtual ICollection Territories { get; set; }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/Invoice.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class Invoice
7 | {
8 | public string? ShipName { get; set; }
9 | public string? ShipAddress { get; set; }
10 | public string? ShipCity { get; set; }
11 | public string? ShipRegion { get; set; }
12 | public string? ShipPostalCode { get; set; }
13 | public string? ShipCountry { get; set; }
14 | public string? CustomerId { get; set; }
15 | public string CustomerName { get; set; } = null!;
16 | public string? Address { get; set; }
17 | public string? City { get; set; }
18 | public string? Region { get; set; }
19 | public string? PostalCode { get; set; }
20 | public string? Country { get; set; }
21 | public string Salesperson { get; set; } = null!;
22 | public int OrderId { get; set; }
23 | public DateTime? OrderDate { get; set; }
24 | public DateTime? RequiredDate { get; set; }
25 | public DateTime? ShippedDate { get; set; }
26 | public string ShipperName { get; set; } = null!;
27 | public int ProductId { get; set; }
28 | public string ProductName { get; set; } = null!;
29 | public decimal UnitPrice { get; set; }
30 | public short Quantity { get; set; }
31 | public float Discount { get; set; }
32 | public decimal? ExtendedPrice { get; set; }
33 | public decimal? Freight { get; set; }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/Order.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class Order
7 | {
8 | public Order()
9 | {
10 | OrderDetails = new HashSet();
11 | }
12 |
13 | public int OrderId { get; set; }
14 | public string? CustomerId { get; set; }
15 | public int? EmployeeId { get; set; }
16 | public DateTime? OrderDate { get; set; }
17 | public DateTime? RequiredDate { get; set; }
18 | public DateTime? ShippedDate { get; set; }
19 | public int? ShipVia { get; set; }
20 | public decimal? Freight { get; set; }
21 | public string? ShipName { get; set; }
22 | public string? ShipAddress { get; set; }
23 | public string? ShipCity { get; set; }
24 | public string? ShipRegion { get; set; }
25 | public string? ShipPostalCode { get; set; }
26 | public string? ShipCountry { get; set; }
27 |
28 | public virtual Customer? Customer { get; set; }
29 | public virtual Employee? Employee { get; set; }
30 | public virtual Shipper? ShipViaNavigation { get; set; }
31 | public virtual ICollection OrderDetails { get; set; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/OrderDetail.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class OrderDetail
7 | {
8 | public int OrderId { get; set; }
9 | public int ProductId { get; set; }
10 | public decimal UnitPrice { get; set; }
11 | public short Quantity { get; set; }
12 | public float Discount { get; set; }
13 |
14 | public virtual Order Order { get; set; } = null!;
15 | public virtual Product Product { get; set; } = null!;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/OrderDetailsExtended.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class OrderDetailsExtended
7 | {
8 | public int OrderId { get; set; }
9 | public int ProductId { get; set; }
10 | public string ProductName { get; set; } = null!;
11 | public decimal UnitPrice { get; set; }
12 | public short Quantity { get; set; }
13 | public float Discount { get; set; }
14 | public decimal? ExtendedPrice { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/OrderSubtotal.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class OrderSubtotal
7 | {
8 | public int OrderId { get; set; }
9 | public decimal? Subtotal { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/OrdersQry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class OrdersQry
7 | {
8 | public int OrderId { get; set; }
9 | public string? CustomerId { get; set; }
10 | public int? EmployeeId { get; set; }
11 | public DateTime? OrderDate { get; set; }
12 | public DateTime? RequiredDate { get; set; }
13 | public DateTime? ShippedDate { get; set; }
14 | public int? ShipVia { get; set; }
15 | public decimal? Freight { get; set; }
16 | public string? ShipName { get; set; }
17 | public string? ShipAddress { get; set; }
18 | public string? ShipCity { get; set; }
19 | public string? ShipRegion { get; set; }
20 | public string? ShipPostalCode { get; set; }
21 | public string? ShipCountry { get; set; }
22 | public string CompanyName { get; set; } = null!;
23 | public string? Address { get; set; }
24 | public string? City { get; set; }
25 | public string? Region { get; set; }
26 | public string? PostalCode { get; set; }
27 | public string? Country { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/Product.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class Product
7 | {
8 | public Product()
9 | {
10 | OrderDetails = new HashSet();
11 | }
12 |
13 | public int ProductId { get; set; }
14 | public string ProductName { get; set; } = null!;
15 | public int? SupplierId { get; set; }
16 | public int? CategoryId { get; set; }
17 | public string? QuantityPerUnit { get; set; }
18 | public decimal? UnitPrice { get; set; }
19 | public short? UnitsInStock { get; set; }
20 | public short? UnitsOnOrder { get; set; }
21 | public short? ReorderLevel { get; set; }
22 | public bool Discontinued { get; set; }
23 |
24 | public virtual Category? Category { get; set; }
25 | public virtual Supplier? Supplier { get; set; }
26 | public virtual ICollection OrderDetails { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/ProductSalesFor1997.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class ProductSalesFor1997
7 | {
8 | public string CategoryName { get; set; } = null!;
9 | public string ProductName { get; set; } = null!;
10 | public decimal? ProductSales { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/ProductsAboveAveragePrice.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class ProductsAboveAveragePrice
7 | {
8 | public string ProductName { get; set; } = null!;
9 | public decimal? UnitPrice { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/ProductsByCategory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class ProductsByCategory
7 | {
8 | public string CategoryName { get; set; } = null!;
9 | public string ProductName { get; set; } = null!;
10 | public string? QuantityPerUnit { get; set; }
11 | public short? UnitsInStock { get; set; }
12 | public bool Discontinued { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/QuarterlyOrder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class QuarterlyOrder
7 | {
8 | public string? CustomerId { get; set; }
9 | public string? CompanyName { get; set; }
10 | public string? City { get; set; }
11 | public string? Country { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/Region.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class Region
7 | {
8 | public Region()
9 | {
10 | Territories = new HashSet();
11 | }
12 |
13 | public int RegionId { get; set; }
14 | public string RegionDescription { get; set; } = null!;
15 |
16 | public virtual ICollection Territories { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/SalesByCategory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class SalesByCategory
7 | {
8 | public int CategoryId { get; set; }
9 | public string CategoryName { get; set; } = null!;
10 | public string ProductName { get; set; } = null!;
11 | public decimal? ProductSales { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/SalesTotalsByAmount.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class SalesTotalsByAmount
7 | {
8 | public decimal? SaleAmount { get; set; }
9 | public int OrderId { get; set; }
10 | public string CompanyName { get; set; } = null!;
11 | public DateTime? ShippedDate { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/Shipper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class Shipper
7 | {
8 | public Shipper()
9 | {
10 | Orders = new HashSet();
11 | }
12 |
13 | public int ShipperId { get; set; }
14 | public string CompanyName { get; set; } = null!;
15 | public string? Phone { get; set; }
16 |
17 | public virtual ICollection Orders { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/SummaryOfSalesByQuarter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class SummaryOfSalesByQuarter
7 | {
8 | public DateTime? ShippedDate { get; set; }
9 | public int OrderId { get; set; }
10 | public decimal? Subtotal { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/SummaryOfSalesByYear.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class SummaryOfSalesByYear
7 | {
8 | public DateTime? ShippedDate { get; set; }
9 | public int OrderId { get; set; }
10 | public decimal? Subtotal { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/Supplier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class Supplier
7 | {
8 | public Supplier()
9 | {
10 | Products = new HashSet();
11 | }
12 |
13 | public int SupplierId { get; set; }
14 | public string CompanyName { get; set; } = null!;
15 | public string? ContactName { get; set; }
16 | public string? ContactTitle { get; set; }
17 | public string? Address { get; set; }
18 | public string? City { get; set; }
19 | public string? Region { get; set; }
20 | public string? PostalCode { get; set; }
21 | public string? Country { get; set; }
22 | public string? Phone { get; set; }
23 | public string? Fax { get; set; }
24 | public string? HomePage { get; set; }
25 |
26 | public virtual ICollection Products { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/Models/Territory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ORM_SQL_İzalasyonu.Models
5 | {
6 | public partial class Territory
7 | {
8 | public Territory()
9 | {
10 | Employees = new HashSet();
11 | }
12 |
13 | public string TerritoryId { get; set; } = null!;
14 | public string TerritoryDescription { get; set; } = null!;
15 | public int RegionId { get; set; }
16 |
17 | public virtual Region Region { get; set; } = null!;
18 |
19 | public virtual ICollection Employees { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/ORM_SQL_İzolasyonu.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | Always
17 |
18 |
19 |
20 |
21 |
22 |
23 | all
24 | runtime; build; native; contentfiles; analyzers; buildtransitive
25 |
26 |
27 |
28 | all
29 | runtime; build; native; contentfiles; analyzers; buildtransitive
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/ORM_SQL_İzalasyonu/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Password": "****"
3 | }
--------------------------------------------------------------------------------
/One_to_Many_Relationship/Migrations/20220823202226_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace One_to_Many_Relationship.Migrations
6 | {
7 | public partial class mig_1 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.CreateTable(
12 | name: "Departmanlar",
13 | columns: table => new
14 | {
15 | Id = table.Column(type: "int", nullable: false)
16 | .Annotation("SqlServer:Identity", "1, 1"),
17 | DepartmanAdi = table.Column(type: "nvarchar(max)", nullable: false)
18 | },
19 | constraints: table =>
20 | {
21 | table.PrimaryKey("PK_Departmanlar", x => x.Id);
22 | });
23 |
24 | migrationBuilder.CreateTable(
25 | name: "Calisanlar",
26 | columns: table => new
27 | {
28 | Id = table.Column(type: "int", nullable: false)
29 | .Annotation("SqlServer:Identity", "1, 1"),
30 | DId = table.Column(type: "int", nullable: false),
31 | Adi = table.Column(type: "nvarchar(max)", nullable: false)
32 | },
33 | constraints: table =>
34 | {
35 | table.PrimaryKey("PK_Calisanlar", x => x.Id);
36 | table.ForeignKey(
37 | name: "FK_Calisanlar_Departmanlar_DId",
38 | column: x => x.DId,
39 | principalTable: "Departmanlar",
40 | principalColumn: "Id",
41 | onDelete: ReferentialAction.Cascade);
42 | });
43 |
44 | migrationBuilder.CreateIndex(
45 | name: "IX_Calisanlar_DId",
46 | table: "Calisanlar",
47 | column: "DId");
48 | }
49 |
50 | protected override void Down(MigrationBuilder migrationBuilder)
51 | {
52 | migrationBuilder.DropTable(
53 | name: "Calisanlar");
54 |
55 | migrationBuilder.DropTable(
56 | name: "Departmanlar");
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/One_to_Many_Relationship/One_to_Many_Relationship.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/One_to_One_Relationship/Migrations/20220820205639_mig_1.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | #nullable disable
9 |
10 | namespace One_to_One_Relationship.Migrations
11 | {
12 | [DbContext(typeof(ESirketDbContext))]
13 | [Migration("20220820205639_mig_1")]
14 | partial class mig_1
15 | {
16 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("ProductVersion", "6.0.8")
21 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
22 |
23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
24 |
25 | modelBuilder.Entity("Calisan", b =>
26 | {
27 | b.Property("Id")
28 | .ValueGeneratedOnAdd()
29 | .HasColumnType("int");
30 |
31 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
32 |
33 | b.Property("Adi")
34 | .IsRequired()
35 | .HasColumnType("nvarchar(max)");
36 |
37 | b.HasKey("Id");
38 |
39 | b.ToTable("Calisanlar");
40 | });
41 |
42 | modelBuilder.Entity("CalisanAdresi", b =>
43 | {
44 | b.Property("Id")
45 | .HasColumnType("int");
46 |
47 | b.Property("Adres")
48 | .IsRequired()
49 | .HasColumnType("nvarchar(max)");
50 |
51 | b.HasKey("Id");
52 |
53 | b.ToTable("CalisanAdresleri");
54 | });
55 |
56 | modelBuilder.Entity("CalisanAdresi", b =>
57 | {
58 | b.HasOne("Calisan", "Calisan")
59 | .WithOne("CalisanAdresi")
60 | .HasForeignKey("CalisanAdresi", "Id")
61 | .OnDelete(DeleteBehavior.Cascade)
62 | .IsRequired();
63 |
64 | b.Navigation("Calisan");
65 | });
66 |
67 | modelBuilder.Entity("Calisan", b =>
68 | {
69 | b.Navigation("CalisanAdresi")
70 | .IsRequired();
71 | });
72 | #pragma warning restore 612, 618
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/One_to_One_Relationship/Migrations/20220820205639_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace One_to_One_Relationship.Migrations
6 | {
7 | public partial class mig_1 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.CreateTable(
12 | name: "Calisanlar",
13 | columns: table => new
14 | {
15 | Id = table.Column(type: "int", nullable: false)
16 | .Annotation("SqlServer:Identity", "1, 1"),
17 | Adi = table.Column(type: "nvarchar(max)", nullable: false)
18 | },
19 | constraints: table =>
20 | {
21 | table.PrimaryKey("PK_Calisanlar", x => x.Id);
22 | });
23 |
24 | migrationBuilder.CreateTable(
25 | name: "CalisanAdresleri",
26 | columns: table => new
27 | {
28 | Id = table.Column(type: "int", nullable: false),
29 | Adres = table.Column(type: "nvarchar(max)", nullable: false)
30 | },
31 | constraints: table =>
32 | {
33 | table.PrimaryKey("PK_CalisanAdresleri", x => x.Id);
34 | table.ForeignKey(
35 | name: "FK_CalisanAdresleri_Calisanlar_Id",
36 | column: x => x.Id,
37 | principalTable: "Calisanlar",
38 | principalColumn: "Id",
39 | onDelete: ReferentialAction.Cascade);
40 | });
41 | }
42 |
43 | protected override void Down(MigrationBuilder migrationBuilder)
44 | {
45 | migrationBuilder.DropTable(
46 | name: "CalisanAdresleri");
47 |
48 | migrationBuilder.DropTable(
49 | name: "Calisanlar");
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/One_to_One_Relationship/Migrations/ESirketDbContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
6 |
7 | #nullable disable
8 |
9 | namespace One_to_One_Relationship.Migrations
10 | {
11 | [DbContext(typeof(ESirketDbContext))]
12 | partial class ESirketDbContextModelSnapshot : ModelSnapshot
13 | {
14 | protected override void BuildModel(ModelBuilder modelBuilder)
15 | {
16 | #pragma warning disable 612, 618
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "6.0.8")
19 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
20 |
21 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
22 |
23 | modelBuilder.Entity("Calisan", b =>
24 | {
25 | b.Property("Id")
26 | .ValueGeneratedOnAdd()
27 | .HasColumnType("int");
28 |
29 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
30 |
31 | b.Property("Adi")
32 | .IsRequired()
33 | .HasColumnType("nvarchar(max)");
34 |
35 | b.HasKey("Id");
36 |
37 | b.ToTable("Calisanlar");
38 | });
39 |
40 | modelBuilder.Entity("CalisanAdresi", b =>
41 | {
42 | b.Property("Id")
43 | .HasColumnType("int");
44 |
45 | b.Property("Adres")
46 | .IsRequired()
47 | .HasColumnType("nvarchar(max)");
48 |
49 | b.HasKey("Id");
50 |
51 | b.ToTable("CalisanAdresleri");
52 | });
53 |
54 | modelBuilder.Entity("CalisanAdresi", b =>
55 | {
56 | b.HasOne("Calisan", "Calisan")
57 | .WithOne("CalisanAdresi")
58 | .HasForeignKey("CalisanAdresi", "Id")
59 | .OnDelete(DeleteBehavior.Cascade)
60 | .IsRequired();
61 |
62 | b.Navigation("Calisan");
63 | });
64 |
65 | modelBuilder.Entity("Calisan", b =>
66 | {
67 | b.Navigation("CalisanAdresi")
68 | .IsRequired();
69 | });
70 | #pragma warning restore 612, 618
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/One_to_One_Relationship/One_to_One_Relationship.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Owned_Entities_and_Table_Splitting/Owned_Entities_and_Table_Splitting.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Persisting_The_Data/Migrations/20220716103730_mig_1.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | #nullable disable
9 |
10 | namespace Persisting_The_Data.Migrations
11 | {
12 | [DbContext(typeof(ETicaretContext))]
13 | [Migration("20220716103730_mig_1")]
14 | partial class mig_1
15 | {
16 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("ProductVersion", "6.0.5")
21 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
22 |
23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
24 |
25 | modelBuilder.Entity("Urun", b =>
26 | {
27 | b.Property("Id")
28 | .ValueGeneratedOnAdd()
29 | .HasColumnType("int");
30 |
31 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
32 |
33 | b.Property("Fiyat")
34 | .HasColumnType("real");
35 |
36 | b.Property("UrunAdi")
37 | .IsRequired()
38 | .HasColumnType("nvarchar(max)");
39 |
40 | b.HasKey("Id");
41 |
42 | b.ToTable("Urunler");
43 | });
44 | #pragma warning restore 612, 618
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Persisting_The_Data/Migrations/20220716103730_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Persisting_The_Data.Migrations
6 | {
7 | public partial class mig_1 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.CreateTable(
12 | name: "Urunler",
13 | columns: table => new
14 | {
15 | Id = table.Column(type: "int", nullable: false)
16 | .Annotation("SqlServer:Identity", "1, 1"),
17 | UrunAdi = table.Column(type: "nvarchar(max)", nullable: false),
18 | Fiyat = table.Column(type: "real", nullable: false)
19 | },
20 | constraints: table =>
21 | {
22 | table.PrimaryKey("PK_Urunler", x => x.Id);
23 | });
24 | }
25 |
26 | protected override void Down(MigrationBuilder migrationBuilder)
27 | {
28 | migrationBuilder.DropTable(
29 | name: "Urunler");
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Persisting_The_Data/Migrations/ETicaretContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
6 |
7 | #nullable disable
8 |
9 | namespace Persisting_The_Data.Migrations
10 | {
11 | [DbContext(typeof(ETicaretContext))]
12 | partial class ETicaretContextModelSnapshot : ModelSnapshot
13 | {
14 | protected override void BuildModel(ModelBuilder modelBuilder)
15 | {
16 | #pragma warning disable 612, 618
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "6.0.5")
19 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
20 |
21 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
22 |
23 | modelBuilder.Entity("Urun", b =>
24 | {
25 | b.Property("Id")
26 | .ValueGeneratedOnAdd()
27 | .HasColumnType("int");
28 |
29 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
30 |
31 | b.Property("Fiyat")
32 | .HasColumnType("real");
33 |
34 | b.Property("UrunAdi")
35 | .IsRequired()
36 | .HasColumnType("nvarchar(max)");
37 |
38 | b.HasKey("Id");
39 |
40 | b.ToTable("Urunler");
41 | });
42 | #pragma warning restore 612, 618
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Persisting_The_Data/Persisting_The_Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Persisting_The_Data_Delete/Persisting_The_Data_Delete.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers; buildtransitive
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Persisting_The_Data_Delete/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | Console.WriteLine();
3 |
4 | #region Veri Nasıl Silinir?
5 | //ETicaretContext context = new();
6 | //Urun urun = await context.Urunler.FirstOrDefaultAsync(u => u.Id == 5);
7 | //context.Urunler.Remove(urun);
8 | //await context.SaveChangesAsync();
9 | #endregion
10 | #region Silme İşleminde ChangeTracker'ın Rolü
11 | //ChangeTracker, context üzerinden gelen verilerin takibinden sorumlu bir mekanizmadır. Bu takip mekanizması sayesinde context üzerinden gelen verilerle ilgili işlemler neticesinde update yahut delete sorgularının oluşturulacağı anlaşılır!
12 | #endregion
13 | #region Takip Edilmeyen Nesneler Nasıl Silinir?
14 | //ETicaretContext context = new();
15 | //Urun u = new()
16 | //{
17 | // Id = 2
18 | //};
19 | //context.Urunler.Remove(u);
20 | //await context.SaveChangesAsync();
21 |
22 | #region EntityState İle Silme İşlemi
23 | //Urun u = new() { Id = 1 };
24 | //context.Entry(u).State = EntityState.Deleted;
25 | //await context.SaveChangesAsync();
26 | #endregion
27 | #endregion
28 | #region Birden Fazla Veri Silinirken Nelere Dikkat Edilmelidir?
29 | #region SaveChanges'ı Verimli Kullanalım
30 |
31 | #endregion
32 | #region RemoveRange
33 | //ETicaretContext context = new();
34 | //List urunler = await context.Urunler.Where(u => u.Id >= 7 && u.Id <= 9).ToListAsync();
35 | //context.Urunler.RemoveRange(urunler);
36 | //await context.SaveChangesAsync();
37 | #endregion
38 | #endregion
39 |
40 |
41 | public class ETicaretContext : DbContext
42 | {
43 | public DbSet Urunler { get; set; }
44 |
45 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
46 | {
47 | optionsBuilder.UseSqlServer("Server=localhost, 1433;Database=ETicaretDB;User ID=SA;Password=1q2w3e4r+!");
48 | }
49 | }
50 | public class Urun
51 | {
52 | public int Id { get; set; }
53 | public string UrunAdi { get; set; }
54 | public float Fiyat { get; set; }
55 | }
--------------------------------------------------------------------------------
/Persisting_The_Data_Update/Migrations/20220723093252_mig_1.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | #nullable disable
9 |
10 | namespace Persisting_The_Data_Update.Migrations
11 | {
12 | [DbContext(typeof(ETicaretContext))]
13 | [Migration("20220723093252_mig_1")]
14 | partial class mig_1
15 | {
16 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("ProductVersion", "6.0.7")
21 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
22 |
23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
24 |
25 | modelBuilder.Entity("Urun", b =>
26 | {
27 | b.Property("Id")
28 | .ValueGeneratedOnAdd()
29 | .HasColumnType("int");
30 |
31 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
32 |
33 | b.Property("Fiyat")
34 | .HasColumnType("real");
35 |
36 | b.Property("UrunAdi")
37 | .IsRequired()
38 | .HasColumnType("nvarchar(max)");
39 |
40 | b.HasKey("Id");
41 |
42 | b.ToTable("Urunler");
43 | });
44 | #pragma warning restore 612, 618
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Persisting_The_Data_Update/Migrations/20220723093252_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Persisting_The_Data_Update.Migrations
6 | {
7 | public partial class mig_1 : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.CreateTable(
12 | name: "Urunler",
13 | columns: table => new
14 | {
15 | Id = table.Column(type: "int", nullable: false)
16 | .Annotation("SqlServer:Identity", "1, 1"),
17 | UrunAdi = table.Column(type: "nvarchar(max)", nullable: false),
18 | Fiyat = table.Column(type: "real", nullable: false)
19 | },
20 | constraints: table =>
21 | {
22 | table.PrimaryKey("PK_Urunler", x => x.Id);
23 | });
24 | }
25 |
26 | protected override void Down(MigrationBuilder migrationBuilder)
27 | {
28 | migrationBuilder.DropTable(
29 | name: "Urunler");
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Persisting_The_Data_Update/Migrations/ETicaretContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Metadata;
5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
6 |
7 | #nullable disable
8 |
9 | namespace Persisting_The_Data_Update.Migrations
10 | {
11 | [DbContext(typeof(ETicaretContext))]
12 | partial class ETicaretContextModelSnapshot : ModelSnapshot
13 | {
14 | protected override void BuildModel(ModelBuilder modelBuilder)
15 | {
16 | #pragma warning disable 612, 618
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "6.0.7")
19 | .HasAnnotation("Relational:MaxIdentifierLength", 128);
20 |
21 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
22 |
23 | modelBuilder.Entity("Urun", b =>
24 | {
25 | b.Property("Id")
26 | .ValueGeneratedOnAdd()
27 | .HasColumnType("int");
28 |
29 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
30 |
31 | b.Property("Fiyat")
32 | .HasColumnType("real");
33 |
34 | b.Property("UrunAdi")
35 | .IsRequired()
36 | .HasColumnType("nvarchar(max)");
37 |
38 | b.HasKey("Id");
39 |
40 | b.ToTable("Urunler");
41 | });
42 | #pragma warning restore 612, 618
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Persisting_The_Data_Update/Persisting_The_Data_Update.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Query_Log/Migrations/20221203091028_mig_1.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace QueryLog.Migrations
6 | {
7 | ///
8 | public partial class mig1 : Migration
9 | {
10 | ///
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.CreateTable(
14 | name: "Persons",
15 | columns: table => new
16 | {
17 | PersonId = table.Column(type: "int", nullable: false)
18 | .Annotation("SqlServer:Identity", "1, 1"),
19 | Name = table.Column(type: "nvarchar(max)", nullable: false)
20 | },
21 | constraints: table =>
22 | {
23 | table.PrimaryKey("PK_Persons", x => x.PersonId);
24 | });
25 |
26 | migrationBuilder.CreateTable(
27 | name: "Orders",
28 | columns: table => new
29 | {
30 | OrderId = table.Column(type: "int", nullable: false)
31 | .Annotation("SqlServer:Identity", "1, 1"),
32 | PersonId = table.Column(type: "int", nullable: false),
33 | Description = table.Column(type: "nvarchar(max)", nullable: false),
34 | Price = table.Column(type: "int", nullable: false)
35 | },
36 | constraints: table =>
37 | {
38 | table.PrimaryKey("PK_Orders", x => x.OrderId);
39 | table.ForeignKey(
40 | name: "FK_Orders_Persons_PersonId",
41 | column: x => x.PersonId,
42 | principalTable: "Persons",
43 | principalColumn: "PersonId",
44 | onDelete: ReferentialAction.Cascade);
45 | });
46 |
47 | migrationBuilder.CreateIndex(
48 | name: "IX_Orders_PersonId",
49 | table: "Orders",
50 | column: "PersonId");
51 | }
52 |
53 | ///
54 | protected override void Down(MigrationBuilder migrationBuilder)
55 | {
56 | migrationBuilder.DropTable(
57 | name: "Orders");
58 |
59 | migrationBuilder.DropTable(
60 | name: "Persons");
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Query_Log/Program.cs:
--------------------------------------------------------------------------------
1 |
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.Extensions.Logging;
4 | using System.Reflection;
5 |
6 | ApplicationDbContext context = new();
7 | #region Query Log Nedir?
8 | //LINQ soprguları neticesinde generate edilen sorguları izleyebilmek ve olası teknik hataları ayıklayabilmek amacıyla query log mekanizmasından istifade etmekteyiz.
9 | #endregion
10 | #region Nasıl Konfigüre Edilir?
11 | //Microsoft.Extensions.Logging.Console
12 |
13 | await context.Persons.ToListAsync();
14 |
15 | await context.Persons
16 | .Include(p => p.Orders)
17 | .Where(p => p.Name.Contains("a"))
18 | .Select(p => new { p.Name, p.PersonId })
19 | .ToListAsync();
20 | #endregion
21 | #region Filtreleme Nasıl Yapılır?
22 |
23 | #endregion
24 |
25 | public class Person
26 | {
27 | public int PersonId { get; set; }
28 | public string Name { get; set; }
29 |
30 | public ICollection Orders { get; set; }
31 | }
32 | public class Order
33 | {
34 | public int OrderId { get; set; }
35 | public int PersonId { get; set; }
36 | public string Description { get; set; }
37 | public int Price { get; set; }
38 |
39 | public Person Person { get; set; }
40 | }
41 | class ApplicationDbContext : DbContext
42 | {
43 | public DbSet Persons { get; set; }
44 | public DbSet Orders { get; set; }
45 | protected override void OnModelCreating(ModelBuilder modelBuilder)
46 | {
47 | modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
48 |
49 | modelBuilder.Entity