Skip to content

Commit

Permalink
added the first migration and dropped the previous hardcoded database…
Browse files Browse the repository at this point in the history
…. Also removed the EnsureCreated method from the Startup class
  • Loading branch information
luizfelipers19 committed Apr 2, 2021
1 parent 8065fa1 commit 9dc49de
Show file tree
Hide file tree
Showing 24 changed files with 306 additions and 17 deletions.
Binary file modified .vs/music/v16/.suo
Binary file not shown.
46 changes: 46 additions & 0 deletions music/Migrations/20210402010235_InitialCreate.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions music/Migrations/20210402010235_InitialCreate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;

namespace music.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Songs",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
Language = table.Column<string>(type: "nvarchar(max)", nullable: true),
Duration = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Songs", x => x.Id);
});
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Songs");
}
}
}
44 changes: 44 additions & 0 deletions music/Migrations/ApiDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using music.Data;

namespace music.Migrations
{
[DbContext(typeof(ApiDbContext))]
partial class ApiDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.4")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

modelBuilder.Entity("music.Models.Song", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Duration")
.HasColumnType("nvarchar(max)");
b.Property<string>("Language")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Songs");
});
#pragma warning restore 612, 618
}
}
}
2 changes: 2 additions & 0 deletions music/Models/Song.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ public class Song
public string Title { get; set; }

public string Language { get; set; }

public string Duration { get; set; }
}
}
4 changes: 2 additions & 2 deletions music/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void ConfigureServices(IServiceCollection services)
{

services.AddControllers();
services.AddMvc().AddXmlSerializerFormatters();
services.AddMvc().AddXmlSerializerFormatters();

services.AddSwaggerGen(c =>
{
Expand All @@ -49,7 +49,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApiDbCon
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "music v1"));
}

dbContext.Database.EnsureCreated();
// dbContext.Database.EnsureCreated(); => removed this line because we are now using Migrations

app.UseHttpsRedirection();

Expand Down
Binary file added music/bin/Debug/net5.0/Humanizer.dll
Binary file not shown.
Binary file not shown.
62 changes: 55 additions & 7 deletions music/bin/Debug/net5.0/music.deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"dependencies": {
"Microsoft.EntityFrameworkCore": "5.0.4",
"Microsoft.EntityFrameworkCore.SqlServer": "5.0.4",
"Microsoft.EntityFrameworkCore.Tools": "5.0.4",
"Swashbuckle.AspNetCore": "5.6.3",
"Microsoft.AspNetCore.Antiforgery": "5.0.0.0",
"Microsoft.AspNetCore.Authentication.Abstractions": "5.0.0.0",
Expand Down Expand Up @@ -325,7 +326,15 @@
"music.dll": {}
}
},
"Microsoft.CSharp/4.5.0": {},
"Humanizer.Core/2.8.26": {
"runtime": {
"lib/netstandard2.0/Humanizer.dll": {
"assemblyVersion": "2.8.0.0",
"fileVersion": "2.8.26.1919"
}
}
},
"Microsoft.CSharp/4.7.0": {},
"Microsoft.Data.SqlClient/2.0.1": {
"dependencies": {
"Microsoft.Data.SqlClient.SNI.runtime": "2.0.1",
Expand Down Expand Up @@ -440,6 +449,19 @@
}
},
"Microsoft.EntityFrameworkCore.Analyzers/5.0.4": {},
"Microsoft.EntityFrameworkCore.Design/5.0.4": {
"dependencies": {
"Humanizer.Core": "2.8.26",
"Microsoft.CSharp": "4.7.0",
"Microsoft.EntityFrameworkCore.Relational": "5.0.4"
},
"runtime": {
"lib/netstandard2.1/Microsoft.EntityFrameworkCore.Design.dll": {
"assemblyVersion": "5.0.4.0",
"fileVersion": "5.0.421.11803"
}
}
},
"Microsoft.EntityFrameworkCore.Relational/5.0.4": {
"dependencies": {
"Microsoft.EntityFrameworkCore": "5.0.4",
Expand Down Expand Up @@ -470,6 +492,11 @@
"lib/netstandard2.1/Microsoft.EntityFrameworkCore.SqlServer.dll": {}
}
},
"Microsoft.EntityFrameworkCore.Tools/5.0.4": {
"dependencies": {
"Microsoft.EntityFrameworkCore.Design": "5.0.4"
}
},
"Microsoft.Extensions.ApiDescription.Server/3.0.0": {},
"Microsoft.Extensions.Caching.Abstractions/5.0.0": {
"dependencies": {
Expand Down Expand Up @@ -523,7 +550,7 @@
"Microsoft.Extensions.Primitives/5.0.0": {},
"Microsoft.Identity.Client/4.14.0": {
"dependencies": {
"Microsoft.CSharp": "4.5.0",
"Microsoft.CSharp": "4.7.0",
"System.ComponentModel.TypeConverter": "4.3.0",
"System.Net.NameResolution": "4.3.0",
"System.Private.Uri": "4.3.2",
Expand Down Expand Up @@ -639,7 +666,7 @@
},
"Newtonsoft.Json/10.0.1": {
"dependencies": {
"Microsoft.CSharp": "4.5.0",
"Microsoft.CSharp": "4.7.0",
"System.Collections": "4.3.0",
"System.ComponentModel.TypeConverter": "4.3.0",
"System.Diagnostics.Debug": "4.3.0",
Expand Down Expand Up @@ -3040,12 +3067,19 @@
"serviceable": false,
"sha512": ""
},
"Microsoft.CSharp/4.5.0": {
"Humanizer.Core/2.8.26": {
"type": "package",
"serviceable": true,
"sha512": "sha512-OiKusGL20vby4uDEswj2IgkdchC1yQ6rwbIkZDVBPIR6al2b7n3pC91elBul9q33KaBgRKhbZH3+2Ur4fnWx2A==",
"path": "humanizer.core/2.8.26",
"hashPath": "humanizer.core.2.8.26.nupkg.sha512"
},
"Microsoft.CSharp/4.7.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kaj6Wb4qoMuH3HySFJhxwQfe8R/sJsNJnANrvv8WdFPMoNbKY5htfNscv+LHCu5ipz+49m2e+WQXpLXr9XYemQ==",
"path": "microsoft.csharp/4.5.0",
"hashPath": "microsoft.csharp.4.5.0.nupkg.sha512"
"sha512": "sha512-pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==",
"path": "microsoft.csharp/4.7.0",
"hashPath": "microsoft.csharp.4.7.0.nupkg.sha512"
},
"Microsoft.Data.SqlClient/2.0.1": {
"type": "package",
Expand Down Expand Up @@ -3082,6 +3116,13 @@
"path": "microsoft.entityframeworkcore.analyzers/5.0.4",
"hashPath": "microsoft.entityframeworkcore.analyzers.5.0.4.nupkg.sha512"
},
"Microsoft.EntityFrameworkCore.Design/5.0.4": {
"type": "package",
"serviceable": true,
"sha512": "sha512-LqyE5MX0IUFjsXu3tNIMpTtC4poY7XQogpGdATjK949tCKopxyJuzTZtgsgdc20LGFWQM0UwwyyfUNjs5kKvsw==",
"path": "microsoft.entityframeworkcore.design/5.0.4",
"hashPath": "microsoft.entityframeworkcore.design.5.0.4.nupkg.sha512"
},
"Microsoft.EntityFrameworkCore.Relational/5.0.4": {
"type": "package",
"serviceable": true,
Expand All @@ -3096,6 +3137,13 @@
"path": "microsoft.entityframeworkcore.sqlserver/5.0.4",
"hashPath": "microsoft.entityframeworkcore.sqlserver.5.0.4.nupkg.sha512"
},
"Microsoft.EntityFrameworkCore.Tools/5.0.4": {
"type": "package",
"serviceable": true,
"sha512": "sha512-ldiZtmhBXJBvBHLUUglCL2n0RFoaXwR3fnvY0Tn0U70V4gafA2ny7vf1d/Gh4ai9qyj/wVJOj4RN8HAy4wjqTw==",
"path": "microsoft.entityframeworkcore.tools/5.0.4",
"hashPath": "microsoft.entityframeworkcore.tools.5.0.4.nupkg.sha512"
},
"Microsoft.Extensions.ApiDescription.Server/3.0.0": {
"type": "package",
"serviceable": true,
Expand Down
Binary file modified music/bin/Debug/net5.0/music.dll
Binary file not shown.
Binary file modified music/bin/Debug/net5.0/music.pdb
Binary file not shown.
Binary file modified music/bin/Debug/net5.0/ref/music.dll
Binary file not shown.
4 changes: 4 additions & 0 deletions music/music.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>

Expand Down
Binary file modified music/obj/Debug/net5.0/music.assets.cache
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14449d00be21023cde1eda072e7e9f907fbed054
abb098dd360adfdcdd96e32b22706a9214941cb1
2 changes: 2 additions & 0 deletions music/obj/Debug/net5.0/music.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ C:\Users\Windows\Desktop\Estudo\APIs\music\music\music\bin\Debug\net5.0\runtimes
C:\Users\Windows\Desktop\Estudo\APIs\music\music\music\bin\Debug\net5.0\runtimes\win-x86\native\Microsoft.Data.SqlClient.SNI.pdb
C:\Users\Windows\Desktop\Estudo\APIs\music\music\music\bin\Debug\net5.0\runtimes\win\lib\netstandard2.0\System.Runtime.Caching.dll
C:\Users\Windows\Desktop\Estudo\APIs\music\music\music\bin\Debug\net5.0\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll
C:\Users\Windows\Desktop\Estudo\APIs\music\music\music\bin\Debug\net5.0\Humanizer.dll
C:\Users\Windows\Desktop\Estudo\APIs\music\music\music\bin\Debug\net5.0\Microsoft.EntityFrameworkCore.Design.dll
Binary file modified music/obj/Debug/net5.0/music.csprojAssemblyReference.cache
Binary file not shown.
Binary file modified music/obj/Debug/net5.0/music.dll
Binary file not shown.
Binary file modified music/obj/Debug/net5.0/music.pdb
Binary file not shown.
Binary file modified music/obj/Debug/net5.0/ref/music.dll
Binary file not shown.
6 changes: 6 additions & 0 deletions music/obj/music.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
"target": "Package",
"version": "[5.0.4, )"
},
"Microsoft.EntityFrameworkCore.Tools": {
"include": "Runtime, Build, Native, ContentFiles, Analyzers, BuildTransitive",
"suppressParent": "All",
"target": "Package",
"version": "[5.0.4, )"
},
"Swashbuckle.AspNetCore": {
"target": "Package",
"version": "[5.6.3, )"
Expand Down
2 changes: 2 additions & 0 deletions music/obj/music.csproj.nuget.g.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)microsoft.extensions.apidescription.server\3.0.0\build\Microsoft.Extensions.ApiDescription.Server.props" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.apidescription.server\3.0.0\build\Microsoft.Extensions.ApiDescription.Server.props')" />
<Import Project="$(NuGetPackageRoot)swashbuckle.aspnetcore\5.6.3\build\Swashbuckle.AspNetCore.props" Condition="Exists('$(NuGetPackageRoot)swashbuckle.aspnetcore\5.6.3\build\Swashbuckle.AspNetCore.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.entityframeworkcore.design\5.0.4\build\netcoreapp3.0\Microsoft.EntityFrameworkCore.Design.props" Condition="Exists('$(NuGetPackageRoot)microsoft.entityframeworkcore.design\5.0.4\build\netcoreapp3.0\Microsoft.EntityFrameworkCore.Design.props')" />
</ImportGroup>
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<PkgNewtonsoft_Json Condition=" '$(PkgNewtonsoft_Json)' == '' ">C:\Users\Windows\.nuget\packages\newtonsoft.json\10.0.1</PkgNewtonsoft_Json>
<PkgMicrosoft_Extensions_ApiDescription_Server Condition=" '$(PkgMicrosoft_Extensions_ApiDescription_Server)' == '' ">C:\Users\Windows\.nuget\packages\microsoft.extensions.apidescription.server\3.0.0</PkgMicrosoft_Extensions_ApiDescription_Server>
<PkgMicrosoft_EntityFrameworkCore_Tools Condition=" '$(PkgMicrosoft_EntityFrameworkCore_Tools)' == '' ">C:\Users\Windows\.nuget\packages\microsoft.entityframeworkcore.tools\5.0.4</PkgMicrosoft_EntityFrameworkCore_Tools>
</PropertyGroup>
</Project>
Loading

0 comments on commit 9dc49de

Please sign in to comment.