Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/blank-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Blank issue
about: Create an issue to help us improve
---

# Before you open an issue

If the issue is with an ASP.NET Core document:

* Do **not** open a new issue using this form.
* Open the issue using the **Open a documentation issue** link and feedback form at the bottom of the article.

Using the **Open a documentation issue** link and form to open an issue adds article metadata for tracking, which indicates the article that you're commenting on and pings the author for a faster response.

If the issue is:

* A simple typo or similar correction, you can submit a PR. See the Contributor Guide for instructions: https://docs.microsoft.com/contribute/#quick-edits-to-existing-documents
* A general support question, consider asking on a support forum:
* Stack Overflow: https://stackoverflow.com/questions/tagged/asp.net-core
* ASP.NET Core Slack: https://aspnetcore.slack.com/join/shared_invite/zt-1mv5487zb-EOZxJ1iqb0A0ajowEbxByQ#/shared-invite/email
* ASP.NET Gitter: https://gitter.im/aspnet/Home
* A site design concern, create an issue at MicrosoftDocs/Feedback: https://github.com/MicrosoftDocs/Feedback/issues/new/choose
* A problem completing a tutorial, compare your code with the completed sample.
* A duplicate of an open or closed issue, leave a comment on that issue.
9 changes: 6 additions & 3 deletions .github/ISSUE_TEMPLATE/doc-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ Using the **Open a documentation issue** link and form to open an issue adds art

If the issue is:

* A simple typo or similar correction, you can submit a PR. See [the contributor guide](https://docs.microsoft.com/contribute/#quick-edits-to-existing-documents) for instructions.
* A general support question, consider asking on a support forum site.
* A site design concern, create an issue at [MicrosoftDocs/Feedback](https://github.com/MicrosoftDocs/Feedback/issues/new/choose).
* A simple typo or similar correction, you can submit a PR. See the Contributor Guide for instructions: https://docs.microsoft.com/contribute/#quick-edits-to-existing-documents
* A general support question, consider asking on a support forum:
* Stack Overflow: https://stackoverflow.com/questions/tagged/asp.net-core
* ASP.NET Core Slack: https://aspnetcore.slack.com/join/shared_invite/zt-1mv5487zb-EOZxJ1iqb0A0ajowEbxByQ#/shared-invite/email
* ASP.NET Gitter: https://gitter.im/aspnet/Home
* A site design concern, create an issue at MicrosoftDocs/Feedback: https://github.com/MicrosoftDocs/Feedback/issues/new/choose
* A problem completing a tutorial, compare your code with the completed sample.
* A duplicate of an open or closed issue, leave a comment on that issue.

Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,23 @@ This repository contains the [ASP.NET Core documentation](https://learn.microsof
To provide comments and suggestions on [learn.microsoft.com](https://learn.microsoft.com) site functionality, open an issue in the [`MicrosoftDocs/feedback` GitHub repository](https://github.com/MicrosoftDocs/feedback).

ASP.NET 4.x documentation changes are made in the [`dotnet/AspNetDocs` GitHub repository](https://github.com/dotnet/AspNetDocs).

## How to open an issue

If the issue is with an ASP.NET Core document:

* Do **not** open a blank issue.
* Open the issue using the **Open a documentation issue** link and feedback form at the bottom of the article.

Using the **Open a documentation issue** link and form to open an issue adds article metadata for tracking, which indicates the article that you're commenting on and automatically pings the author for a faster response.

If the issue is:

* A simple typo or similar correction, you can submit a PR. See [the contributor guide](https://docs.microsoft.com/contribute/#quick-edits-to-existing-documents) for instructions.
* A general support question, consider asking on a support forum site:
* [Stack Overflow](https://stackoverflow.com/questions/tagged/asp.net-core)
* [ASP.NET Core Slack](https://aspnetcore.slack.com/join/shared_invite/zt-1mv5487zb-EOZxJ1iqb0A0ajowEbxByQ#/shared-invite/email)
* [ASP.NET Gitter](https://gitter.im/aspnet/Home)
* A site design concern, create an issue at [MicrosoftDocs/Feedback](https://github.com/MicrosoftDocs/Feedback/issues/new/choose).
* A problem completing a tutorial, compare your code with the completed sample.
* A duplicate of an open or closed issue, leave a comment on that issue.
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions aspnetcore/data/ef-rp/intro/samples/cu90/ContosoUniversity.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<!-- -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>$(DefineConstants)TRACE;SQLiteVersion</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SQLite" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.0" />
</ItemGroup>

</Project>
69 changes: 69 additions & 0 deletions aspnetcore/data/ef-rp/intro/samples/cu90/Data/DbInitializer1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#define FIRST
#if FIRST // First DbInitializer used
// <snippet>
using ContosoUniversity.Models;

namespace ContosoUniversity.Data
{
public static class DbInitializer
{
public static void Initialize(SchoolContext context)
{
// Look for any students.
if (context.Students.Any())
{
return; // DB has been seeded
}

var students = new Student[]
{
new Student{FirstMidName="Carson",LastName="Alexander",EnrollmentDate=DateTime.Parse("2019-09-01")},
new Student{FirstMidName="Meredith",LastName="Alonso",EnrollmentDate=DateTime.Parse("2017-09-01")},
new Student{FirstMidName="Arturo",LastName="Anand",EnrollmentDate=DateTime.Parse("2018-09-01")},
new Student{FirstMidName="Gytis",LastName="Barzdukas",EnrollmentDate=DateTime.Parse("2017-09-01")},
new Student{FirstMidName="Yan",LastName="Li",EnrollmentDate=DateTime.Parse("2017-09-01")},
new Student{FirstMidName="Peggy",LastName="Justice",EnrollmentDate=DateTime.Parse("2016-09-01")},
new Student{FirstMidName="Laura",LastName="Norman",EnrollmentDate=DateTime.Parse("2018-09-01")},
new Student{FirstMidName="Nino",LastName="Olivetto",EnrollmentDate=DateTime.Parse("2019-09-01")}
};

context.Students.AddRange(students);
context.SaveChanges();

var courses = new Course[]
{
new Course{CourseID=1050,Title="Chemistry",Credits=3},
new Course{CourseID=4022,Title="Microeconomics",Credits=3},
new Course{CourseID=4041,Title="Macroeconomics",Credits=3},
new Course{CourseID=1045,Title="Calculus",Credits=4},
new Course{CourseID=3141,Title="Trigonometry",Credits=4},
new Course{CourseID=2021,Title="Composition",Credits=3},
new Course{CourseID=2042,Title="Literature",Credits=4}
};

context.Courses.AddRange(courses);
context.SaveChanges();

var enrollments = new Enrollment[]
{
new Enrollment{StudentID=1,CourseID=1050,Grade=Grade.A},
new Enrollment{StudentID=1,CourseID=4022,Grade=Grade.C},
new Enrollment{StudentID=1,CourseID=4041,Grade=Grade.B},
new Enrollment{StudentID=2,CourseID=1045,Grade=Grade.B},
new Enrollment{StudentID=2,CourseID=3141,Grade=Grade.F},
new Enrollment{StudentID=2,CourseID=2021,Grade=Grade.F},
new Enrollment{StudentID=3,CourseID=1050},
new Enrollment{StudentID=4,CourseID=1050},
new Enrollment{StudentID=4,CourseID=4022,Grade=Grade.F},
new Enrollment{StudentID=5,CourseID=4041,Grade=Grade.C},
new Enrollment{StudentID=6,CourseID=1045},
new Enrollment{StudentID=7,CourseID=3141,Grade=Grade.A},
};

context.Enrollments.AddRange(enrollments);
context.SaveChanges();
}
}
}
// </snippet>
#endif
30 changes: 30 additions & 0 deletions aspnetcore/data/ef-rp/intro/samples/cu90/Data/SchoolContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#define First // LAST First
#if First
// <snippet_first>
using ContosoUniversity.Models;
using Microsoft.EntityFrameworkCore;

namespace ContosoUniversity.Data
{
public class SchoolContext : DbContext
{
public SchoolContext (DbContextOptions<SchoolContext> options)
: base(options)
{
}

public DbSet<Student> Students { get; set; }
public DbSet<Enrollment> Enrollments { get; set; }
public DbSet<Course> Courses { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Course>().ToTable("Course");
modelBuilder.Entity<Enrollment>().ToTable("Enrollment");
modelBuilder.Entity<Student>().ToTable("Student");
}
}
}
// </snippet_first>
#elif LAST
#endif
46 changes: 46 additions & 0 deletions aspnetcore/data/ef-rp/intro/samples/cu90/Models/Course.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#define FIRST
#if FIRST
// <snippet_first>
using System.ComponentModel.DataAnnotations.Schema;

namespace ContosoUniversity.Models
{
public class Course
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int CourseID { get; set; }
public string Title { get; set; }
public int Credits { get; set; }

public ICollection<Enrollment> Enrollments { get; set; }
}
}
// </snippet_first>
#elif LAST
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace ContosoUniversity.Models
{
// <snippet_last>
public class Course
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Display(Name = "Number")]
public int CourseID { get; set; }

[StringLength(50, MinimumLength = 3)]
public string Title { get; set; }

[Range(0, 5)]
public int Credits { get; set; }

public int DepartmentID { get; set; }

public Department Department { get; set; }
public ICollection<Enrollment> Enrollments { get; set; }
public ICollection<Instructor> Instructors { get; set; }
}
}
// </snippet_last>
#endif
106 changes: 106 additions & 0 deletions aspnetcore/data/ef-rp/intro/samples/cu90/Models/Department.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#define FIRST
#if FIRST
// <snippet1>
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace ContosoUniversity.Models
{
public class Department
{
public int DepartmentID { get; set; }

[StringLength(50, MinimumLength = 3)]
public string Name { get; set; }

[DataType(DataType.Currency)]
[Column(TypeName = "money")]
public decimal Budget { get; set; }

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}",
ApplyFormatInEditMode = true)]
[Display(Name = "Start Date")]
public DateTime StartDate { get; set; }

public int? InstructorID { get; set; }

public Instructor Administrator { get; set; }
public ICollection<Course> Courses { get; set; }
}
}
// </snippet1>
#else
#if SQLiteVersion
// <snippetSL>
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace ContosoUniversity.Models
{
public class Department
{
public int DepartmentID { get; set; }

[StringLength(50, MinimumLength = 3)]
public string Name { get; set; }

[DataType(DataType.Currency)]
[Column(TypeName = "money")]
public decimal Budget { get; set; }

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}",
ApplyFormatInEditMode = true)]
[Display(Name = "Start Date")]
public DateTime StartDate { get; set; }

public int? InstructorID { get; set; }

public Guid ConcurrencyToken { get; set; } = Guid.NewGuid();

public Instructor Administrator { get; set; }
public ICollection<Course> Courses { get; set; }
}
}
// </snippetSL>
#else // SQL Server version with concurrency token
// <snippet3>
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace ContosoUniversity.Models
{
public class Department
{
public int DepartmentID { get; set; }

[StringLength(50, MinimumLength = 3)]
public string Name { get; set; }

[DataType(DataType.Currency)]
[Column(TypeName = "money")]
public decimal Budget { get; set; }

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}",
ApplyFormatInEditMode = true)]
[Display(Name = "Start Date")]
public DateTime StartDate { get; set; }

public int? InstructorID { get; set; }

[Timestamp]
public byte[] ConcurrencyToken { get; set; }

public Instructor Administrator { get; set; }
public ICollection<Course> Courses { get; set; }
}
}
// </snippet3>
#endif
#endif
21 changes: 21 additions & 0 deletions aspnetcore/data/ef-rp/intro/samples/cu90/Models/Enrollment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;

namespace ContosoUniversity.Models
{
public enum Grade
{
A, B, C, D, F
}

public class Enrollment
{
public int EnrollmentID { get; set; }
public int CourseID { get; set; }
public int StudentID { get; set; }
[DisplayFormat(NullDisplayText = "No grade")]
public Grade? Grade { get; set; }

public Course Course { get; set; }
public Student Student { get; set; }
}
}
Loading
Loading