├── WebApplication4 ├── appsettings.Development.json ├── Models │ ├── sp_alterdiagramResult.cs │ ├── sp_creatediagramResult.cs │ ├── sp_dropdiagramResult.cs │ ├── sp_helpdiagramsResult.cs │ ├── sp_renamediagramResult.cs │ ├── Department_DeleteResult.cs │ ├── sp_upgraddiagramsResult.cs │ ├── sp_helpdiagramdefinitionResult.cs │ ├── Department_UpdateResult.cs │ ├── Department_InsertResult.cs │ ├── VwDepartmentCourseCount.cs │ ├── OfficeAssignment.cs │ ├── CourseInstructor.cs │ ├── VwCourseStudentCount.cs │ ├── Enrollment.cs │ ├── GetCourseReportResult.cs │ ├── VwCourseStudent.cs │ ├── Course.Partial.cs │ ├── Department.cs │ ├── Course.cs │ ├── Person.cs │ ├── DbContextExtensions.cs │ ├── ContosoUniversityContext.cs │ └── ContosoUniversityContextProcedures.cs ├── WeatherForecast.cs ├── appsettings.json ├── Program.cs ├── Properties │ └── launchSettings.json ├── WebApplication4.csproj ├── Controllers │ ├── WeatherForecastController.cs │ └── CoursesController.cs ├── Startup.cs └── efpt.config.json ├── WebApplication4.sln ├── .gitattributes └── .gitignore /WebApplication4/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WebApplication4/Models/sp_alterdiagramResult.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WebApplication4.Models 7 | { 8 | public partial class sp_alterdiagramResult 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApplication4/Models/sp_creatediagramResult.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WebApplication4.Models 7 | { 8 | public partial class sp_creatediagramResult 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApplication4/Models/sp_dropdiagramResult.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WebApplication4.Models 7 | { 8 | public partial class sp_dropdiagramResult 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApplication4/Models/sp_helpdiagramsResult.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WebApplication4.Models 7 | { 8 | public partial class sp_helpdiagramsResult 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApplication4/Models/sp_renamediagramResult.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WebApplication4.Models 7 | { 8 | public partial class sp_renamediagramResult 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApplication4/Models/Department_DeleteResult.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WebApplication4.Models 7 | { 8 | public partial class Department_DeleteResult 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApplication4/Models/sp_upgraddiagramsResult.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WebApplication4.Models 7 | { 8 | public partial class sp_upgraddiagramsResult 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApplication4/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WebApplication4 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /WebApplication4/Models/sp_helpdiagramdefinitionResult.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WebApplication4.Models 7 | { 8 | public partial class sp_helpdiagramdefinitionResult 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApplication4/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Initial Catalog=ContosoUniversity;Integrated Security=True" 4 | }, 5 | "Logging": { 6 | "LogLevel": { 7 | "Default": "Information", 8 | "Microsoft": "Warning", 9 | "Microsoft.Hosting.Lifetime": "Information" 10 | } 11 | }, 12 | "AllowedHosts": "*" 13 | } 14 | -------------------------------------------------------------------------------- /WebApplication4/Models/Department_UpdateResult.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WebApplication4.Models 7 | { 8 | public partial class Department_UpdateResult 9 | { 10 | public byte[] RowVersion { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /WebApplication4/Models/Department_InsertResult.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WebApplication4.Models 7 | { 8 | public partial class Department_InsertResult 9 | { 10 | public int DepartmentID { get; set; } 11 | public byte[] RowVersion { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WebApplication4/Models/VwDepartmentCourseCount.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | #nullable disable 6 | 7 | namespace WebApplication4.Models 8 | { 9 | public partial class VwDepartmentCourseCount 10 | { 11 | public int DepartmentId { get; set; } 12 | public string Name { get; set; } 13 | public int? CourseCount { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /WebApplication4/Models/OfficeAssignment.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | #nullable disable 6 | 7 | namespace WebApplication4.Models 8 | { 9 | public partial class OfficeAssignment 10 | { 11 | public int InstructorId { get; set; } 12 | public string Location { get; set; } 13 | 14 | public virtual Person Instructor { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /WebApplication4/Models/CourseInstructor.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | #nullable disable 6 | 7 | namespace WebApplication4.Models 8 | { 9 | public partial class CourseInstructor 10 | { 11 | public int CourseId { get; set; } 12 | public int InstructorId { get; set; } 13 | 14 | public virtual Course Course { get; set; } 15 | public virtual Person Instructor { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WebApplication4/Models/VwCourseStudentCount.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | #nullable disable 6 | 7 | namespace WebApplication4.Models 8 | { 9 | public partial class VwCourseStudentCount 10 | { 11 | public int? DepartmentId { get; set; } 12 | public string Name { get; set; } 13 | public int CourseId { get; set; } 14 | public string Title { get; set; } 15 | public int? StudentCount { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WebApplication4/Models/Enrollment.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | #nullable disable 6 | 7 | namespace WebApplication4.Models 8 | { 9 | public partial class Enrollment 10 | { 11 | public int EnrollmentId { get; set; } 12 | public int CourseId { get; set; } 13 | public int StudentId { get; set; } 14 | public int? Grade { get; set; } 15 | 16 | public virtual Course Course { get; set; } 17 | public virtual Person Student { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /WebApplication4/Models/GetCourseReportResult.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | 6 | namespace WebApplication4.Models 7 | { 8 | public partial class GetCourseReportResult 9 | { 10 | public int CourseID { get; set; } 11 | public string CourseName { get; set; } 12 | public int? TeacherCount { get; set; } 13 | public int? StudentCount { get; set; } 14 | public double? AvgGrade { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WebApplication4/Models/VwCourseStudent.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | #nullable disable 6 | 7 | namespace WebApplication4.Models 8 | { 9 | public partial class VwCourseStudent 10 | { 11 | public int? DepartmentId { get; set; } 12 | public string DepartmentName { get; set; } 13 | public int CourseId { get; set; } 14 | public string CourseTitle { get; set; } 15 | public int? StudentId { get; set; } 16 | public string StudentName { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /WebApplication4/Models/Course.Partial.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using Microsoft.AspNetCore.Mvc; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | #nullable disable 8 | 9 | namespace WebApplication4.Models 10 | { 11 | [ModelMetadataType(typeof(CourseMetadata))] 12 | public partial class Course 13 | { 14 | } 15 | 16 | internal class CourseMetadata 17 | { 18 | [Required] 19 | public string Title { get; set; } 20 | [Required] 21 | public int Credits { get; set; } 22 | } 23 | } -------------------------------------------------------------------------------- /WebApplication4/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebApplication4 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /WebApplication4/Models/Department.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | #nullable disable 6 | 7 | namespace WebApplication4.Models 8 | { 9 | public partial class Department 10 | { 11 | public Department() 12 | { 13 | Courses = new HashSet(); 14 | } 15 | 16 | public int DepartmentId { get; set; } 17 | public string Name { get; set; } 18 | public decimal Budget { get; set; } 19 | public DateTime? StartDate { get; set; } 20 | public int? InstructorId { get; set; } 21 | public byte[] RowVersion { get; set; } 22 | public bool IsDeleted { get; set; } 23 | 24 | public virtual Person Instructor { get; set; } 25 | public virtual ICollection Courses { get; set; } 26 | } 27 | } -------------------------------------------------------------------------------- /WebApplication4/Models/Course.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | #nullable disable 6 | 7 | namespace WebApplication4.Models 8 | { 9 | public partial class Course 10 | { 11 | public Course() 12 | { 13 | CourseInstructors = new HashSet(); 14 | Enrollments = new HashSet(); 15 | } 16 | 17 | public int CourseId { get; set; } 18 | public string Title { get; set; } 19 | public int Credits { get; set; } 20 | public int DepartmentId { get; set; } 21 | 22 | public virtual Department Department { get; set; } 23 | public virtual ICollection CourseInstructors { get; set; } 24 | public virtual ICollection Enrollments { get; set; } 25 | } 26 | } -------------------------------------------------------------------------------- /WebApplication4/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:1151", 8 | "sslPort": 44390 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "swagger", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "WebApplication4": { 21 | "commandName": "Project", 22 | "dotnetRunMessages": "true", 23 | "launchBrowser": true, 24 | "launchUrl": "swagger", 25 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /WebApplication4/WebApplication4.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /WebApplication4/Models/Person.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | #nullable disable 6 | 7 | namespace WebApplication4.Models 8 | { 9 | public partial class Person 10 | { 11 | public Person() 12 | { 13 | CourseInstructors = new HashSet(); 14 | Departments = new HashSet(); 15 | Enrollments = new HashSet(); 16 | } 17 | 18 | public int Id { get; set; } 19 | public string LastName { get; set; } 20 | public string FirstName { get; set; } 21 | public DateTime? HireDate { get; set; } 22 | public DateTime? EnrollmentDate { get; set; } 23 | public string Discriminator { get; set; } 24 | 25 | public virtual OfficeAssignment OfficeAssignment { get; set; } 26 | public virtual ICollection CourseInstructors { get; set; } 27 | public virtual ICollection Departments { get; set; } 28 | public virtual ICollection Enrollments { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /WebApplication4.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30717.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication4", "WebApplication4\WebApplication4.csproj", "{61355FEE-9FDB-4A15-8AB4-D0B3894E262D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {61355FEE-9FDB-4A15-8AB4-D0B3894E262D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {61355FEE-9FDB-4A15-8AB4-D0B3894E262D}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {61355FEE-9FDB-4A15-8AB4-D0B3894E262D}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {61355FEE-9FDB-4A15-8AB4-D0B3894E262D}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A7F6F097-3A78-4611-9F90-017C7EF3AF6B} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /WebApplication4/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.Extensions.Logging; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebApplication4.Controllers 9 | { 10 | [ApiController] 11 | [Route("[controller]")] 12 | public class WeatherForecastController : ControllerBase 13 | { 14 | private static readonly string[] Summaries = new[] 15 | { 16 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 17 | }; 18 | 19 | private readonly ILogger _logger; 20 | 21 | public WeatherForecastController(ILogger logger) 22 | { 23 | _logger = logger; 24 | } 25 | 26 | [HttpGet] 27 | public IEnumerable Get() 28 | { 29 | var rng = new Random(); 30 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 31 | { 32 | Date = DateTime.Now.AddDays(index), 33 | TemperatureC = rng.Next(-20, 55), 34 | Summary = Summaries[rng.Next(Summaries.Length)] 35 | }) 36 | .ToArray(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /WebApplication4/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.HttpsPolicy; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | using Microsoft.OpenApi.Models; 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Linq; 13 | using System.Threading.Tasks; 14 | using Microsoft.EntityFrameworkCore; 15 | using WebApplication4.Models; 16 | 17 | namespace WebApplication4 18 | { 19 | public class Startup 20 | { 21 | public Startup(IConfiguration configuration) 22 | { 23 | Configuration = configuration; 24 | } 25 | 26 | public IConfiguration Configuration { get; } 27 | 28 | // This method gets called by the runtime. Use this method to add services to the container. 29 | public void ConfigureServices(IServiceCollection services) 30 | { 31 | services.AddDbContext(options => 32 | options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); 33 | 34 | 35 | services.AddControllers(); 36 | services.AddSwaggerGen(c => 37 | { 38 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "WebApplication4", Version = "v1" }); 39 | }); 40 | } 41 | 42 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 43 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 44 | { 45 | if (env.IsDevelopment()) 46 | { 47 | app.UseDeveloperExceptionPage(); 48 | app.UseSwagger(); 49 | app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebApplication4 v1")); 50 | } 51 | 52 | app.UseHttpsRedirection(); 53 | 54 | app.UseRouting(); 55 | 56 | app.UseAuthorization(); 57 | 58 | app.UseEndpoints(endpoints => 59 | { 60 | endpoints.MapControllers(); 61 | }); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /WebApplication4/Models/DbContextExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Storage; 5 | using System; 6 | using System.Data.Common; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebApplication4.Models 10 | { 11 | public static class DbContextExtensions 12 | { 13 | public static async Task SqlQuery(this DbContext db, string sql, params object[] parameters) where T : class 14 | { 15 | using (var db2 = new ContextForQueryType(db.Database.GetDbConnection(), db.Database.CurrentTransaction)) 16 | { 17 | return await db2.Set().FromSqlRaw(sql, parameters).ToArrayAsync(); 18 | } 19 | } 20 | 21 | private class ContextForQueryType : DbContext where T : class 22 | { 23 | private readonly DbConnection connection; 24 | private readonly IDbContextTransaction transaction; 25 | 26 | public ContextForQueryType(DbConnection connection, IDbContextTransaction tran) 27 | { 28 | this.connection = connection; 29 | this.transaction = tran; 30 | 31 | if (tran != null) 32 | { 33 | this.Database.UseTransaction((tran as IInfrastructure).Instance); 34 | } 35 | } 36 | 37 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 38 | { 39 | if (transaction != null) 40 | { 41 | optionsBuilder.UseSqlServer(connection); 42 | } 43 | else 44 | { 45 | optionsBuilder.UseSqlServer(connection, options => options.EnableRetryOnFailure()); 46 | } 47 | } 48 | 49 | protected override void OnModelCreating(ModelBuilder modelBuilder) 50 | { 51 | modelBuilder.Entity().HasNoKey().ToView(null); 52 | } 53 | } 54 | } 55 | 56 | public class OutputParameter 57 | { 58 | private bool _valueSet = false; 59 | 60 | public TValue _value; 61 | public TValue Value 62 | { 63 | get 64 | { 65 | if (!_valueSet) 66 | throw new InvalidOperationException("Value not set."); 67 | 68 | return _value; 69 | } 70 | } 71 | 72 | internal void SetValue(object value) 73 | { 74 | _valueSet = true; 75 | 76 | _value = null == value || Convert.IsDBNull(value) ? default(TValue) : (TValue)value; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /WebApplication4/Controllers/CoursesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Http; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.EntityFrameworkCore; 8 | using WebApplication4.Models; 9 | 10 | namespace WebApplication4.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class CoursesController : ControllerBase 15 | { 16 | private readonly ContosoUniversityContext _context; 17 | 18 | public CoursesController(ContosoUniversityContext context) 19 | { 20 | _context = context; 21 | } 22 | 23 | // GET: api/Courses 24 | [HttpGet] 25 | public async Task>> GetCourses() 26 | { 27 | return await _context.Courses.ToListAsync(); 28 | } 29 | 30 | // GET: api/Courses/5 31 | [HttpGet("{id}")] 32 | public async Task> GetCourse(int id) 33 | { 34 | var course = await _context.Courses.FindAsync(id); 35 | 36 | if (course == null) 37 | { 38 | return NotFound(); 39 | } 40 | 41 | return course; 42 | } 43 | 44 | // PUT: api/Courses/5 45 | // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 46 | [HttpPut("{id}")] 47 | public async Task PutCourse(int id, Course course) 48 | { 49 | if (id != course.CourseId) 50 | { 51 | return BadRequest(); 52 | } 53 | 54 | _context.Entry(course).State = EntityState.Modified; 55 | 56 | try 57 | { 58 | await _context.SaveChangesAsync(); 59 | } 60 | catch (DbUpdateConcurrencyException) 61 | { 62 | if (!CourseExists(id)) 63 | { 64 | return NotFound(); 65 | } 66 | else 67 | { 68 | throw; 69 | } 70 | } 71 | 72 | return NoContent(); 73 | } 74 | 75 | // POST: api/Courses 76 | // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 77 | [HttpPost] 78 | public async Task> PostCourse(Course course) 79 | { 80 | _context.Courses.Add(course); 81 | await _context.SaveChangesAsync(); 82 | 83 | return CreatedAtAction("GetCourse", new { id = course.CourseId }, course); 84 | } 85 | 86 | // DELETE: api/Courses/5 87 | [HttpDelete("{id}")] 88 | public async Task DeleteCourse(int id) 89 | { 90 | var course = await _context.Courses.FindAsync(id); 91 | if (course == null) 92 | { 93 | return NotFound(); 94 | } 95 | 96 | _context.Courses.Remove(course); 97 | await _context.SaveChangesAsync(); 98 | 99 | return NoContent(); 100 | } 101 | 102 | private bool CourseExists(int id) 103 | { 104 | return _context.Courses.Any(e => e.CourseId == id); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /WebApplication4/efpt.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "ContextClassName": "ContosoUniversityContext", 3 | "ContextNamespace": null, 4 | "DefaultDacpacSchema": null, 5 | "FilterSchemas": false, 6 | "IncludeConnectionString": false, 7 | "ModelNamespace": null, 8 | "OutputContextPath": "Models", 9 | "OutputPath": "Models", 10 | "ProjectRootNamespace": "WebApplication4", 11 | "Schemas": null, 12 | "SelectedHandlebarsLanguage": 0, 13 | "SelectedToBeGenerated": 0, 14 | "Tables": [ 15 | { 16 | "HasPrimaryKey": true, 17 | "Name": "[dbo].[Course]", 18 | "ObjectType": 0 19 | }, 20 | { 21 | "HasPrimaryKey": true, 22 | "Name": "[dbo].[CourseInstructor]", 23 | "ObjectType": 0 24 | }, 25 | { 26 | "HasPrimaryKey": true, 27 | "Name": "[dbo].[Department]", 28 | "ObjectType": 0 29 | }, 30 | { 31 | "HasPrimaryKey": true, 32 | "Name": "[dbo].[Enrollment]", 33 | "ObjectType": 0 34 | }, 35 | { 36 | "HasPrimaryKey": true, 37 | "Name": "[dbo].[OfficeAssignment]", 38 | "ObjectType": 0 39 | }, 40 | { 41 | "HasPrimaryKey": true, 42 | "Name": "[dbo].[Person]", 43 | "ObjectType": 0 44 | }, 45 | { 46 | "HasPrimaryKey": true, 47 | "Name": "[dbo].[vwCourseStudentCount]", 48 | "ObjectType": 0 49 | }, 50 | { 51 | "HasPrimaryKey": true, 52 | "Name": "[dbo].[vwCourseStudents]", 53 | "ObjectType": 0 54 | }, 55 | { 56 | "HasPrimaryKey": true, 57 | "Name": "[dbo].[vwDepartmentCourseCount]", 58 | "ObjectType": 0 59 | }, 60 | { 61 | "HasPrimaryKey": true, 62 | "Name": "[dbo].[Department_Delete]", 63 | "ObjectType": 1 64 | }, 65 | { 66 | "HasPrimaryKey": true, 67 | "Name": "[dbo].[Department_Insert]", 68 | "ObjectType": 1 69 | }, 70 | { 71 | "HasPrimaryKey": true, 72 | "Name": "[dbo].[Department_Update]", 73 | "ObjectType": 1 74 | }, 75 | { 76 | "HasPrimaryKey": true, 77 | "Name": "[dbo].[GetCourseReport]", 78 | "ObjectType": 1 79 | }, 80 | { 81 | "HasPrimaryKey": true, 82 | "Name": "[dbo].[sp_alterdiagram]", 83 | "ObjectType": 1 84 | }, 85 | { 86 | "HasPrimaryKey": true, 87 | "Name": "[dbo].[sp_creatediagram]", 88 | "ObjectType": 1 89 | }, 90 | { 91 | "HasPrimaryKey": true, 92 | "Name": "[dbo].[sp_dropdiagram]", 93 | "ObjectType": 1 94 | }, 95 | { 96 | "HasPrimaryKey": true, 97 | "Name": "[dbo].[sp_helpdiagramdefinition]", 98 | "ObjectType": 1 99 | }, 100 | { 101 | "HasPrimaryKey": true, 102 | "Name": "[dbo].[sp_helpdiagrams]", 103 | "ObjectType": 1 104 | }, 105 | { 106 | "HasPrimaryKey": true, 107 | "Name": "[dbo].[sp_renamediagram]", 108 | "ObjectType": 1 109 | }, 110 | { 111 | "HasPrimaryKey": true, 112 | "Name": "[dbo].[sp_upgraddiagrams]", 113 | "ObjectType": 1 114 | } 115 | ], 116 | "UseDatabaseNames": false, 117 | "UseDbContextSplitting": false, 118 | "UseFluentApiOnly": true, 119 | "UseHandleBars": false, 120 | "UseInflector": true, 121 | "UseLegacyPluralizer": false, 122 | "UseNodaTime": false, 123 | "UseSpatial": false 124 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /WebApplication4/Models/ContosoUniversityContext.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Metadata; 5 | 6 | #nullable disable 7 | 8 | namespace WebApplication4.Models 9 | { 10 | public partial class ContosoUniversityContext : DbContext 11 | { 12 | public ContosoUniversityContext() 13 | { 14 | } 15 | 16 | public ContosoUniversityContext(DbContextOptions options) 17 | : base(options) 18 | { 19 | } 20 | 21 | public virtual DbSet Courses { get; set; } 22 | public virtual DbSet CourseInstructors { get; set; } 23 | public virtual DbSet Departments { get; set; } 24 | public virtual DbSet Enrollments { get; set; } 25 | public virtual DbSet OfficeAssignments { get; set; } 26 | public virtual DbSet People { get; set; } 27 | public virtual DbSet VwCourseStudents { get; set; } 28 | public virtual DbSet VwCourseStudentCounts { get; set; } 29 | public virtual DbSet VwDepartmentCourseCounts { get; set; } 30 | 31 | protected override void OnModelCreating(ModelBuilder modelBuilder) 32 | { 33 | modelBuilder.Entity(entity => 34 | { 35 | entity.ToTable("Course"); 36 | 37 | entity.HasIndex(e => e.DepartmentId, "IX_DepartmentID"); 38 | 39 | entity.Property(e => e.CourseId).HasColumnName("CourseID"); 40 | 41 | entity.Property(e => e.DepartmentId) 42 | .HasColumnName("DepartmentID") 43 | .HasDefaultValueSql("((1))"); 44 | 45 | entity.Property(e => e.Title).HasMaxLength(50); 46 | 47 | entity.HasOne(d => d.Department) 48 | .WithMany(p => p.Courses) 49 | .HasForeignKey(d => d.DepartmentId) 50 | .HasConstraintName("FK_dbo.Course_dbo.Department_DepartmentID"); 51 | }); 52 | 53 | modelBuilder.Entity(entity => 54 | { 55 | entity.HasKey(e => new { e.CourseId, e.InstructorId }) 56 | .HasName("PK_dbo.CourseInstructor"); 57 | 58 | entity.ToTable("CourseInstructor"); 59 | 60 | entity.HasIndex(e => e.CourseId, "IX_CourseID"); 61 | 62 | entity.HasIndex(e => e.InstructorId, "IX_InstructorID"); 63 | 64 | entity.Property(e => e.CourseId).HasColumnName("CourseID"); 65 | 66 | entity.Property(e => e.InstructorId).HasColumnName("InstructorID"); 67 | 68 | entity.HasOne(d => d.Course) 69 | .WithMany(p => p.CourseInstructors) 70 | .HasForeignKey(d => d.CourseId) 71 | .HasConstraintName("FK_dbo.CourseInstructor_dbo.Course_CourseID"); 72 | 73 | entity.HasOne(d => d.Instructor) 74 | .WithMany(p => p.CourseInstructors) 75 | .HasForeignKey(d => d.InstructorId) 76 | .HasConstraintName("FK_dbo.CourseInstructor_dbo.Instructor_InstructorID"); 77 | }); 78 | 79 | modelBuilder.Entity(entity => 80 | { 81 | entity.ToTable("Department"); 82 | 83 | entity.HasIndex(e => e.InstructorId, "IX_InstructorID"); 84 | 85 | entity.Property(e => e.DepartmentId).HasColumnName("DepartmentID"); 86 | 87 | entity.Property(e => e.Budget).HasColumnType("money"); 88 | 89 | entity.Property(e => e.InstructorId).HasColumnName("InstructorID"); 90 | 91 | entity.Property(e => e.Name).HasMaxLength(50); 92 | 93 | entity.Property(e => e.RowVersion) 94 | .IsRequired() 95 | .IsRowVersion() 96 | .IsConcurrencyToken(); 97 | 98 | entity.Property(e => e.StartDate).HasColumnType("datetime"); 99 | 100 | entity.HasOne(d => d.Instructor) 101 | .WithMany(p => p.Departments) 102 | .HasForeignKey(d => d.InstructorId) 103 | .HasConstraintName("FK_dbo.Department_dbo.Instructor_InstructorID"); 104 | }); 105 | 106 | modelBuilder.Entity(entity => 107 | { 108 | entity.ToTable("Enrollment"); 109 | 110 | entity.HasIndex(e => e.CourseId, "IX_CourseID"); 111 | 112 | entity.HasIndex(e => e.StudentId, "IX_StudentID"); 113 | 114 | entity.Property(e => e.EnrollmentId).HasColumnName("EnrollmentID"); 115 | 116 | entity.Property(e => e.CourseId).HasColumnName("CourseID"); 117 | 118 | entity.Property(e => e.StudentId).HasColumnName("StudentID"); 119 | 120 | entity.HasOne(d => d.Course) 121 | .WithMany(p => p.Enrollments) 122 | .HasForeignKey(d => d.CourseId) 123 | .HasConstraintName("FK_dbo.Enrollment_dbo.Course_CourseID"); 124 | 125 | entity.HasOne(d => d.Student) 126 | .WithMany(p => p.Enrollments) 127 | .HasForeignKey(d => d.StudentId) 128 | .HasConstraintName("FK_dbo.Enrollment_dbo.Person_StudentID"); 129 | }); 130 | 131 | modelBuilder.Entity(entity => 132 | { 133 | entity.HasKey(e => e.InstructorId) 134 | .HasName("PK_dbo.OfficeAssignment"); 135 | 136 | entity.ToTable("OfficeAssignment"); 137 | 138 | entity.HasIndex(e => e.InstructorId, "IX_InstructorID"); 139 | 140 | entity.Property(e => e.InstructorId) 141 | .ValueGeneratedNever() 142 | .HasColumnName("InstructorID"); 143 | 144 | entity.Property(e => e.Location).HasMaxLength(50); 145 | 146 | entity.HasOne(d => d.Instructor) 147 | .WithOne(p => p.OfficeAssignment) 148 | .HasForeignKey(d => d.InstructorId) 149 | .OnDelete(DeleteBehavior.ClientSetNull) 150 | .HasConstraintName("FK_dbo.OfficeAssignment_dbo.Instructor_InstructorID"); 151 | }); 152 | 153 | modelBuilder.Entity(entity => 154 | { 155 | entity.ToTable("Person"); 156 | 157 | entity.Property(e => e.Id).HasColumnName("ID"); 158 | 159 | entity.Property(e => e.Discriminator) 160 | .IsRequired() 161 | .HasMaxLength(128) 162 | .HasDefaultValueSql("('Instructor')"); 163 | 164 | entity.Property(e => e.EnrollmentDate).HasColumnType("datetime"); 165 | 166 | entity.Property(e => e.FirstName) 167 | .IsRequired() 168 | .HasMaxLength(50); 169 | 170 | entity.Property(e => e.HireDate).HasColumnType("datetime"); 171 | 172 | entity.Property(e => e.LastName) 173 | .IsRequired() 174 | .HasMaxLength(50); 175 | }); 176 | 177 | modelBuilder.Entity(entity => 178 | { 179 | entity.HasNoKey(); 180 | 181 | entity.ToView("vwCourseStudents"); 182 | 183 | entity.Property(e => e.CourseId).HasColumnName("CourseID"); 184 | 185 | entity.Property(e => e.CourseTitle).HasMaxLength(50); 186 | 187 | entity.Property(e => e.DepartmentId).HasColumnName("DepartmentID"); 188 | 189 | entity.Property(e => e.DepartmentName).HasMaxLength(50); 190 | 191 | entity.Property(e => e.StudentId).HasColumnName("StudentID"); 192 | 193 | entity.Property(e => e.StudentName).HasMaxLength(101); 194 | }); 195 | 196 | modelBuilder.Entity(entity => 197 | { 198 | entity.HasNoKey(); 199 | 200 | entity.ToView("vwCourseStudentCount"); 201 | 202 | entity.Property(e => e.CourseId).HasColumnName("CourseID"); 203 | 204 | entity.Property(e => e.DepartmentId).HasColumnName("DepartmentID"); 205 | 206 | entity.Property(e => e.Name).HasMaxLength(50); 207 | 208 | entity.Property(e => e.Title).HasMaxLength(50); 209 | }); 210 | 211 | modelBuilder.Entity(entity => 212 | { 213 | entity.HasNoKey(); 214 | 215 | entity.ToView("vwDepartmentCourseCount"); 216 | 217 | entity.Property(e => e.DepartmentId).HasColumnName("DepartmentID"); 218 | 219 | entity.Property(e => e.Name).HasMaxLength(50); 220 | }); 221 | 222 | OnModelCreatingPartial(modelBuilder); 223 | } 224 | 225 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder); 226 | } 227 | } -------------------------------------------------------------------------------- /WebApplication4/Models/ContosoUniversityContextProcedures.cs: -------------------------------------------------------------------------------- 1 | // This file has been auto generated by EF Core Power Tools. 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.Data.SqlClient; 4 | using System; 5 | using System.Data; 6 | using System.Threading.Tasks; 7 | using WebApplication4.Models; 8 | 9 | namespace WebApplication4.Models 10 | { 11 | public partial class ContosoUniversityContextProcedures 12 | { 13 | private readonly ContosoUniversityContext _context; 14 | 15 | public ContosoUniversityContextProcedures(ContosoUniversityContext context) 16 | { 17 | _context = context; 18 | } 19 | 20 | public async Task Department_Delete(int? DepartmentID, byte[] RowVersion_Original, OutputParameter returnValue = null) 21 | { 22 | var parameterDepartmentID = new SqlParameter 23 | { 24 | ParameterName = "DepartmentID", 25 | Value = DepartmentID ?? Convert.DBNull, 26 | SqlDbType = System.Data.SqlDbType.Int, 27 | }; 28 | 29 | var parameterRowVersion_Original = new SqlParameter 30 | { 31 | ParameterName = "RowVersion_Original", 32 | Value = RowVersion_Original ?? Convert.DBNull, 33 | SqlDbType = System.Data.SqlDbType.Timestamp, 34 | }; 35 | 36 | var parameterreturnValue = new SqlParameter 37 | { 38 | ParameterName = "returnValue", 39 | Direction = System.Data.ParameterDirection.Output, 40 | SqlDbType = System.Data.SqlDbType.Int, 41 | }; 42 | 43 | var _ = await _context.Database.ExecuteSqlRawAsync("EXEC @returnValue = [dbo].[Department_Delete] @DepartmentID, @RowVersion_Original", parameterDepartmentID, parameterRowVersion_Original, parameterreturnValue); 44 | 45 | returnValue?.SetValue(parameterreturnValue.Value); 46 | 47 | return _; 48 | } 49 | 50 | public async Task Department_Insert(string Name, decimal? Budget, DateTime? StartDate, int? InstructorID, OutputParameter returnValue = null) 51 | { 52 | var parameterName = new SqlParameter 53 | { 54 | ParameterName = "Name", 55 | Size = 100, 56 | Value = Name ?? Convert.DBNull, 57 | SqlDbType = System.Data.SqlDbType.NVarChar, 58 | }; 59 | 60 | var parameterBudget = new SqlParameter 61 | { 62 | ParameterName = "Budget", 63 | Value = Budget ?? Convert.DBNull, 64 | SqlDbType = System.Data.SqlDbType.Money, 65 | }; 66 | 67 | var parameterStartDate = new SqlParameter 68 | { 69 | ParameterName = "StartDate", 70 | Value = StartDate ?? Convert.DBNull, 71 | SqlDbType = System.Data.SqlDbType.DateTime, 72 | }; 73 | 74 | var parameterInstructorID = new SqlParameter 75 | { 76 | ParameterName = "InstructorID", 77 | Value = InstructorID ?? Convert.DBNull, 78 | SqlDbType = System.Data.SqlDbType.Int, 79 | }; 80 | 81 | var parameterreturnValue = new SqlParameter 82 | { 83 | ParameterName = "returnValue", 84 | Direction = System.Data.ParameterDirection.Output, 85 | SqlDbType = System.Data.SqlDbType.Int, 86 | }; 87 | 88 | var _ = await _context.SqlQuery("EXEC @returnValue = [dbo].[Department_Insert] @Name, @Budget, @StartDate, @InstructorID", parameterName, parameterBudget, parameterStartDate, parameterInstructorID, parameterreturnValue); 89 | 90 | returnValue?.SetValue(parameterreturnValue.Value); 91 | 92 | return _; 93 | } 94 | 95 | public async Task Department_Update(int? DepartmentID, string Name, decimal? Budget, DateTime? StartDate, int? InstructorID, byte[] RowVersion_Original, OutputParameter returnValue = null) 96 | { 97 | var parameterDepartmentID = new SqlParameter 98 | { 99 | ParameterName = "DepartmentID", 100 | Value = DepartmentID ?? Convert.DBNull, 101 | SqlDbType = System.Data.SqlDbType.Int, 102 | }; 103 | 104 | var parameterName = new SqlParameter 105 | { 106 | ParameterName = "Name", 107 | Size = 100, 108 | Value = Name ?? Convert.DBNull, 109 | SqlDbType = System.Data.SqlDbType.NVarChar, 110 | }; 111 | 112 | var parameterBudget = new SqlParameter 113 | { 114 | ParameterName = "Budget", 115 | Value = Budget ?? Convert.DBNull, 116 | SqlDbType = System.Data.SqlDbType.Money, 117 | }; 118 | 119 | var parameterStartDate = new SqlParameter 120 | { 121 | ParameterName = "StartDate", 122 | Value = StartDate ?? Convert.DBNull, 123 | SqlDbType = System.Data.SqlDbType.DateTime, 124 | }; 125 | 126 | var parameterInstructorID = new SqlParameter 127 | { 128 | ParameterName = "InstructorID", 129 | Value = InstructorID ?? Convert.DBNull, 130 | SqlDbType = System.Data.SqlDbType.Int, 131 | }; 132 | 133 | var parameterRowVersion_Original = new SqlParameter 134 | { 135 | ParameterName = "RowVersion_Original", 136 | Value = RowVersion_Original ?? Convert.DBNull, 137 | SqlDbType = System.Data.SqlDbType.Timestamp, 138 | }; 139 | 140 | var parameterreturnValue = new SqlParameter 141 | { 142 | ParameterName = "returnValue", 143 | Direction = System.Data.ParameterDirection.Output, 144 | SqlDbType = System.Data.SqlDbType.Int, 145 | }; 146 | 147 | var _ = await _context.SqlQuery("EXEC @returnValue = [dbo].[Department_Update] @DepartmentID, @Name, @Budget, @StartDate, @InstructorID, @RowVersion_Original", parameterDepartmentID, parameterName, parameterBudget, parameterStartDate, parameterInstructorID, parameterRowVersion_Original, parameterreturnValue); 148 | 149 | returnValue?.SetValue(parameterreturnValue.Value); 150 | 151 | return _; 152 | } 153 | 154 | public async Task GetCourseReport(int? CourseID, OutputParameter returnValue = null) 155 | { 156 | var parameterCourseID = new SqlParameter 157 | { 158 | ParameterName = "CourseID", 159 | Value = CourseID ?? Convert.DBNull, 160 | SqlDbType = System.Data.SqlDbType.Int, 161 | }; 162 | 163 | var parameterreturnValue = new SqlParameter 164 | { 165 | ParameterName = "returnValue", 166 | Direction = System.Data.ParameterDirection.Output, 167 | SqlDbType = System.Data.SqlDbType.Int, 168 | }; 169 | 170 | var _ = await _context.SqlQuery("EXEC @returnValue = [dbo].[GetCourseReport] @CourseID", parameterCourseID, parameterreturnValue); 171 | 172 | returnValue?.SetValue(parameterreturnValue.Value); 173 | 174 | return _; 175 | } 176 | 177 | public async Task sp_alterdiagram(string diagramname, int? owner_id, int? version, byte[] definition, OutputParameter returnValue = null) 178 | { 179 | var parameterdiagramname = new SqlParameter 180 | { 181 | ParameterName = "diagramname", 182 | Size = 256, 183 | Value = diagramname ?? Convert.DBNull, 184 | SqlDbType = System.Data.SqlDbType.NVarChar, 185 | }; 186 | 187 | var parameterowner_id = new SqlParameter 188 | { 189 | ParameterName = "owner_id", 190 | Value = owner_id ?? Convert.DBNull, 191 | SqlDbType = System.Data.SqlDbType.Int, 192 | }; 193 | 194 | var parameterversion = new SqlParameter 195 | { 196 | ParameterName = "version", 197 | Value = version ?? Convert.DBNull, 198 | SqlDbType = System.Data.SqlDbType.Int, 199 | }; 200 | 201 | var parameterdefinition = new SqlParameter 202 | { 203 | ParameterName = "definition", 204 | Value = definition ?? Convert.DBNull, 205 | SqlDbType = System.Data.SqlDbType.VarBinary, 206 | }; 207 | 208 | var parameterreturnValue = new SqlParameter 209 | { 210 | ParameterName = "returnValue", 211 | Direction = System.Data.ParameterDirection.Output, 212 | SqlDbType = System.Data.SqlDbType.Int, 213 | }; 214 | 215 | var _ = await _context.Database.ExecuteSqlRawAsync("EXEC @returnValue = [dbo].[sp_alterdiagram] @diagramname, @owner_id, @version, @definition", parameterdiagramname, parameterowner_id, parameterversion, parameterdefinition, parameterreturnValue); 216 | 217 | returnValue?.SetValue(parameterreturnValue.Value); 218 | 219 | return _; 220 | } 221 | 222 | public async Task sp_creatediagram(string diagramname, int? owner_id, int? version, byte[] definition, OutputParameter returnValue = null) 223 | { 224 | var parameterdiagramname = new SqlParameter 225 | { 226 | ParameterName = "diagramname", 227 | Size = 256, 228 | Value = diagramname ?? Convert.DBNull, 229 | SqlDbType = System.Data.SqlDbType.NVarChar, 230 | }; 231 | 232 | var parameterowner_id = new SqlParameter 233 | { 234 | ParameterName = "owner_id", 235 | Value = owner_id ?? Convert.DBNull, 236 | SqlDbType = System.Data.SqlDbType.Int, 237 | }; 238 | 239 | var parameterversion = new SqlParameter 240 | { 241 | ParameterName = "version", 242 | Value = version ?? Convert.DBNull, 243 | SqlDbType = System.Data.SqlDbType.Int, 244 | }; 245 | 246 | var parameterdefinition = new SqlParameter 247 | { 248 | ParameterName = "definition", 249 | Value = definition ?? Convert.DBNull, 250 | SqlDbType = System.Data.SqlDbType.VarBinary, 251 | }; 252 | 253 | var parameterreturnValue = new SqlParameter 254 | { 255 | ParameterName = "returnValue", 256 | Direction = System.Data.ParameterDirection.Output, 257 | SqlDbType = System.Data.SqlDbType.Int, 258 | }; 259 | 260 | var _ = await _context.Database.ExecuteSqlRawAsync("EXEC @returnValue = [dbo].[sp_creatediagram] @diagramname, @owner_id, @version, @definition", parameterdiagramname, parameterowner_id, parameterversion, parameterdefinition, parameterreturnValue); 261 | 262 | returnValue?.SetValue(parameterreturnValue.Value); 263 | 264 | return _; 265 | } 266 | 267 | public async Task sp_dropdiagram(string diagramname, int? owner_id, OutputParameter returnValue = null) 268 | { 269 | var parameterdiagramname = new SqlParameter 270 | { 271 | ParameterName = "diagramname", 272 | Size = 256, 273 | Value = diagramname ?? Convert.DBNull, 274 | SqlDbType = System.Data.SqlDbType.NVarChar, 275 | }; 276 | 277 | var parameterowner_id = new SqlParameter 278 | { 279 | ParameterName = "owner_id", 280 | Value = owner_id ?? Convert.DBNull, 281 | SqlDbType = System.Data.SqlDbType.Int, 282 | }; 283 | 284 | var parameterreturnValue = new SqlParameter 285 | { 286 | ParameterName = "returnValue", 287 | Direction = System.Data.ParameterDirection.Output, 288 | SqlDbType = System.Data.SqlDbType.Int, 289 | }; 290 | 291 | var _ = await _context.Database.ExecuteSqlRawAsync("EXEC @returnValue = [dbo].[sp_dropdiagram] @diagramname, @owner_id", parameterdiagramname, parameterowner_id, parameterreturnValue); 292 | 293 | returnValue?.SetValue(parameterreturnValue.Value); 294 | 295 | return _; 296 | } 297 | 298 | public async Task sp_helpdiagramdefinition(string diagramname, int? owner_id, OutputParameter returnValue = null) 299 | { 300 | var parameterdiagramname = new SqlParameter 301 | { 302 | ParameterName = "diagramname", 303 | Size = 256, 304 | Value = diagramname ?? Convert.DBNull, 305 | SqlDbType = System.Data.SqlDbType.NVarChar, 306 | }; 307 | 308 | var parameterowner_id = new SqlParameter 309 | { 310 | ParameterName = "owner_id", 311 | Value = owner_id ?? Convert.DBNull, 312 | SqlDbType = System.Data.SqlDbType.Int, 313 | }; 314 | 315 | var parameterreturnValue = new SqlParameter 316 | { 317 | ParameterName = "returnValue", 318 | Direction = System.Data.ParameterDirection.Output, 319 | SqlDbType = System.Data.SqlDbType.Int, 320 | }; 321 | 322 | var _ = await _context.Database.ExecuteSqlRawAsync("EXEC @returnValue = [dbo].[sp_helpdiagramdefinition] @diagramname, @owner_id", parameterdiagramname, parameterowner_id, parameterreturnValue); 323 | 324 | returnValue?.SetValue(parameterreturnValue.Value); 325 | 326 | return _; 327 | } 328 | 329 | public async Task sp_helpdiagrams(string diagramname, int? owner_id, OutputParameter returnValue = null) 330 | { 331 | var parameterdiagramname = new SqlParameter 332 | { 333 | ParameterName = "diagramname", 334 | Size = 256, 335 | Value = diagramname ?? Convert.DBNull, 336 | SqlDbType = System.Data.SqlDbType.NVarChar, 337 | }; 338 | 339 | var parameterowner_id = new SqlParameter 340 | { 341 | ParameterName = "owner_id", 342 | Value = owner_id ?? Convert.DBNull, 343 | SqlDbType = System.Data.SqlDbType.Int, 344 | }; 345 | 346 | var parameterreturnValue = new SqlParameter 347 | { 348 | ParameterName = "returnValue", 349 | Direction = System.Data.ParameterDirection.Output, 350 | SqlDbType = System.Data.SqlDbType.Int, 351 | }; 352 | 353 | var _ = await _context.Database.ExecuteSqlRawAsync("EXEC @returnValue = [dbo].[sp_helpdiagrams] @diagramname, @owner_id", parameterdiagramname, parameterowner_id, parameterreturnValue); 354 | 355 | returnValue?.SetValue(parameterreturnValue.Value); 356 | 357 | return _; 358 | } 359 | 360 | public async Task sp_renamediagram(string diagramname, int? owner_id, string new_diagramname, OutputParameter returnValue = null) 361 | { 362 | var parameterdiagramname = new SqlParameter 363 | { 364 | ParameterName = "diagramname", 365 | Size = 256, 366 | Value = diagramname ?? Convert.DBNull, 367 | SqlDbType = System.Data.SqlDbType.NVarChar, 368 | }; 369 | 370 | var parameterowner_id = new SqlParameter 371 | { 372 | ParameterName = "owner_id", 373 | Value = owner_id ?? Convert.DBNull, 374 | SqlDbType = System.Data.SqlDbType.Int, 375 | }; 376 | 377 | var parameternew_diagramname = new SqlParameter 378 | { 379 | ParameterName = "new_diagramname", 380 | Size = 256, 381 | Value = new_diagramname ?? Convert.DBNull, 382 | SqlDbType = System.Data.SqlDbType.NVarChar, 383 | }; 384 | 385 | var parameterreturnValue = new SqlParameter 386 | { 387 | ParameterName = "returnValue", 388 | Direction = System.Data.ParameterDirection.Output, 389 | SqlDbType = System.Data.SqlDbType.Int, 390 | }; 391 | 392 | var _ = await _context.Database.ExecuteSqlRawAsync("EXEC @returnValue = [dbo].[sp_renamediagram] @diagramname, @owner_id, @new_diagramname", parameterdiagramname, parameterowner_id, parameternew_diagramname, parameterreturnValue); 393 | 394 | returnValue?.SetValue(parameterreturnValue.Value); 395 | 396 | return _; 397 | } 398 | 399 | public async Task sp_upgraddiagrams(OutputParameter returnValue = null) 400 | { 401 | var parameterreturnValue = new SqlParameter 402 | { 403 | ParameterName = "returnValue", 404 | Direction = System.Data.ParameterDirection.Output, 405 | SqlDbType = System.Data.SqlDbType.Int, 406 | }; 407 | 408 | var _ = await _context.Database.ExecuteSqlRawAsync("EXEC @returnValue = [dbo].[sp_upgraddiagrams]", parameterreturnValue); 409 | 410 | returnValue?.SetValue(parameterreturnValue.Value); 411 | 412 | return _; 413 | } 414 | } 415 | } 416 | --------------------------------------------------------------------------------