Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Changed db to SQLite #60

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions Demo/Prerendering/Demo.Data/Demo.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="MintPlayer.Pagination" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="MintPlayer.Pagination" Version="8.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Demo/Prerendering/Demo.Data/DemoContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
if (configuration == null)
{
// Only used when generating migrations
var migrationsConnectionString = @"Server=(localdb)\mssqllocaldb;Database=RoutingDemo;Trusted_Connection=True;ConnectRetryCount=0";
optionsBuilder.UseSqlServer(migrationsConnectionString, options => options.MigrationsAssembly("Demo.Data"));
var migrationsConnectionString = @"Data Source=demo.db";
optionsBuilder.UseSqlite(migrationsConnectionString, options => options.MigrationsAssembly("Demo.Data"));
}
else
{
optionsBuilder.UseSqlServer(configuration.GetConnectionString("Demo"));
optionsBuilder.UseSqlite(configuration.GetConnectionString("Demo"));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Demo/Prerendering/Demo.Data/Extensions/DemoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static IServiceCollection AddDemo(this IServiceCollection services, Actio
return services
.AddDbContext<DemoContext>(db_options =>
{
db_options.UseSqlServer(opt.ConnectionString, b => b.MigrationsAssembly("Demo.Data"));
db_options.UseSqlite(opt.ConnectionString, b => b.MigrationsAssembly("Demo.Data"));
})
.AddScoped<IPersonRepository, PersonRepository>()
.AddScoped<IPersonService, PersonService>();
Expand Down
29 changes: 0 additions & 29 deletions Demo/Prerendering/Demo.Data/Migrations/20200517091132_AddPeople.cs

This file was deleted.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Demo.Data.Migrations
{
/// <inheritdoc />
public partial class initial_setup : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "People",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
FirstName = table.Column<string>(type: "TEXT", nullable: false),
LastName = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_People", x => x.Id);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "People");
}
}
}
50 changes: 25 additions & 25 deletions Demo/Prerendering/Demo.Data/Migrations/DemoContextModelSnapshot.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
// <auto-generated />
// <auto-generated />
using Demo.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

namespace Demo.Data.Migrations;
#nullable disable

[DbContext(typeof(DemoContext))]
partial class DemoContextModelSnapshot : ModelSnapshot
namespace Demo.Data.Migrations
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
[DbContext(typeof(DemoContext))]
partial class DemoContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");

modelBuilder.Entity("Demo.Data.Entities.Person", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Demo.Data.Entities.Person", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");

b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");

b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");

b.HasKey("Id");
b.HasKey("Id");

b.ToTable("People");
});
b.ToTable("People");
});
#pragma warning restore 612, 618
}
}
}
}
3 changes: 3 additions & 0 deletions Demo/Prerendering/Demo.Web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,6 @@ _Pvt_Extensions

# FAKE - F# Make
.fake/

**.db-shm
**.db-wal
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { SlugifyPipe } from '../../../pipes/slugify.pipe';
FormsModule,
TranslateModule,
SlugifyPipe
],
providers:[
SlugifyPipe
]
})
export class PersonCreateComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import { SlugifyPipe } from '../../../pipes/slugify.pipe';
FormsModule,
TranslateModule,
SlugifyPipe
],
providers: [
SlugifyPipe,
{ provide: 'PERSON', useValue: {} }
]
})
export class PersonEditComponent {
Expand Down
4 changes: 2 additions & 2 deletions Demo/Prerendering/Demo.Web/Demo.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="WebMarkupMin.AspNetCore8" Version="2.15.1-rc2" />
<PackageReference Include="WebMarkupMin.AspNetCore8" Version="2.16.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Binary file added Demo/Prerendering/Demo.Web/RoutingDemo.db
Binary file not shown.
2 changes: 1 addition & 1 deletion Demo/Prerendering/Demo.Web/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
}
},
"ConnectionStrings": {
"Demo": "Server=(localdb)\\mssqllocaldb;Database=RoutingDemo;Trusted_Connection=True;MultipleActiveResultSets=true;ConnectRetryCount=0"
"Demo": "Data Source=RoutingDemo.db"
}
}
2 changes: 1 addition & 1 deletion Demo/Prerendering/Demo.Web/appsettings.Production.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
}
},
"ConnectionStrings": {
"Demo": "Server=(localdb)\\mssqllocaldb;Database=RoutingDemo;Trusted_Connection=True;MultipleActiveResultSets=true;ConnectRetryCount=0"
"Demo": "Data Source=RoutingDemo.db"
}
}
2 changes: 1 addition & 1 deletion Demo/Prerendering/Demo.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
},
"ConnectionStrings": {
"Demo": "Server=(localdb)\\mssqllocaldb;Database=RoutingDemo;Trusted_Connection=True;MultipleActiveResultSets=true;ConnectRetryCount=0"
"Demo": "Data Source=RoutingDemo.db"
},
"AllowedHosts": "*"
}
9 changes: 9 additions & 0 deletions Demo/Prerendering/Demo.Web/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
for ef core migrations use this from project root

`dotnet ef migrations add --startup-project Demo/Prerendering/Demo.Web/Demo.Web.csproj "initial_setup" --project Demo/Prerendering/Demo.Data/Demo.Data.csproj `

and this to update database

` dotnet ef database update --startup-project Demo/Prerendering/Demo.Web/Demo.Web.csproj --project Demo/Prerendering/Demo.Data/Demo.Data.csproj`

this gonna create RoutingDemo.db SQLite file
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Yarn.MSBuild" Version="*" />
<PackageReference Include="Yarn.MSBuild" Version="1.22.19" />
</ItemGroup>

<!-- Version of this SDK is set in global.json -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"sdk": {
"version": "8.0.100-rc.2.23502.2"
"version": "8.0.302"
},
"tools": {
"dotnet": "8.0.100-rc.2.23502.2",
"dotnet": "8.0.302",
"runtimes": {
"dotnet/x64": [
"$(MicrosoftNETCoreAppInternalPackageVersion)"
Expand Down