Skip to content

Commit

Permalink
replaced PostgreSql with Sql Server database
Browse files Browse the repository at this point in the history
  • Loading branch information
suxrobGM committed Jul 23, 2024
1 parent 540e6c3 commit d8fc7ef
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 105 deletions.
2 changes: 1 addition & 1 deletion src/FormBuilder.API/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
throw new ArgumentException("The connection string is not specified");
}

optionsBuilder.ConfigurePostgreSql(_dbContextOptions.ConnectionString);
optionsBuilder.ConfigureSqlServer(_dbContextOptions.ConnectionString);
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
Expand Down
2 changes: 1 addition & 1 deletion src/FormBuilder.API/Data/ApplicationDbContextOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// </summary>
public class ApplicationDbContextOptions
{
private const string DefaultConnectionString = "Host=localhost;Port=5432;Database=FormBuilderDB;Username=postgres;Password=postgres";
private const string DefaultConnectionString = "Data Source=.\\SQLEXPRESS; Database=FormBuilderDB; Trusted_Connection=true; TrustServerCertificate=true;";

/// <summary>
/// The connection string to the database.
Expand Down
6 changes: 3 additions & 3 deletions src/FormBuilder.API/Data/DbContextBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ namespace FormBuilder.API.Data;
internal static class DbContextBuilderExtensions
{
/// <summary>
/// Configures the DbContextOptionsBuilder to use PostgreSQL as the database provider.
/// Configures the DbContextOptionsBuilder to use SQL Server as the database provider.
/// </summary>
/// <param name="options">The DbContextOptionsBuilder to configure.</param>
/// <param name="connectionString">The connection string to use for the database connection.</param>
/// <returns>The configured DbContextOptionsBuilder.</returns>
public static DbContextOptionsBuilder ConfigurePostgreSql(this DbContextOptionsBuilder options, string connectionString)
public static DbContextOptionsBuilder ConfigureSqlServer(this DbContextOptionsBuilder options, string connectionString)
{
options.UseNpgsql(connectionString);
options.UseSqlServer(connectionString);
return options;
}
}
7 changes: 3 additions & 4 deletions src/FormBuilder.API/EntityConfigurations/FormConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ public class FormConfiguration : IEntityTypeConfiguration<Form>
{
public void Configure(EntityTypeBuilder<Form> builder)
{
builder.ToTable("forms");
builder.ToTable("Forms");
builder.HasKey(e => e.Id);
builder.Property(e => e.Id).HasColumnName("id");
builder.Property(e => e.FormName).HasColumnName("form_name");
builder.Property(e => e.FormDesign).HasColumnName("form_design");
builder.Property(e => e.FormName);
builder.Property(e => e.FormDesign);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ public class LovMasterConfiguration : IEntityTypeConfiguration<LovMaster>
{
public void Configure(EntityTypeBuilder<LovMaster> builder)
{
builder.ToTable("lov_master");
builder.ToTable("LovMaster");
builder.HasKey(e => e.Id);
builder.Property(e => e.Id).HasColumnName("id");
builder.Property(e => e.ListId).HasColumnName("list_id");
builder.Property(e => e.ListValue).HasColumnName("list_value");
builder.Property(e => e.ListId);
builder.Property(e => e.ListValue);
}
}
2 changes: 1 addition & 1 deletion src/FormBuilder.API/FormBuilder.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.5"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
</ItemGroup>
Expand Down
52 changes: 0 additions & 52 deletions src/FormBuilder.API/Migrations/20240720030555_Version_0001.cs

This file was deleted.

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

51 changes: 51 additions & 0 deletions src/FormBuilder.API/Migrations/20240723225418_Version_0001.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace FormBuilder.API.Migrations
{
/// <inheritdoc />
public partial class Version_0001 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Forms",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
FormName = table.Column<string>(type: "nvarchar(max)", nullable: true),
FormDesign = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Forms", x => x.Id);
});

migrationBuilder.CreateTable(
name: "LovMaster",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ListId = table.Column<int>(type: "int", nullable: true),
ListValue = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_LovMaster", x => x.Id);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Forms");

migrationBuilder.DropTable(
name: "LovMaster");
}
}
}
30 changes: 12 additions & 18 deletions src/FormBuilder.API/Migrations/ApplicationDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using FormBuilder.API.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

Expand All @@ -18,49 +18,43 @@ protected override void BuildModel(ModelBuilder modelBuilder)
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
.HasAnnotation("Relational:MaxIdentifierLength", 128);

NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

modelBuilder.Entity("FormBuilder.API.Entities.Form", b =>
{
b.Property<string>("Id")
.HasColumnType("text")
.HasColumnName("id");
.HasColumnType("nvarchar(450)");

b.Property<string>("FormDesign")
.HasColumnType("text")
.HasColumnName("form_design");
.HasColumnType("nvarchar(max)");

b.Property<string>("FormName")
.HasColumnType("text")
.HasColumnName("form_name");
.HasColumnType("nvarchar(max)");

b.HasKey("Id");

b.ToTable("forms", (string)null);
b.ToTable("Forms", (string)null);
});

modelBuilder.Entity("FormBuilder.API.Entities.LovMaster", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
.HasColumnType("int");

NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

b.Property<int?>("ListId")
.HasColumnType("integer")
.HasColumnName("list_id");
.HasColumnType("int");

b.Property<string>("ListValue")
.HasColumnType("text")
.HasColumnName("list_value");
.HasColumnType("nvarchar(max)");

b.HasKey("Id");

b.ToTable("lov_master", (string)null);
b.ToTable("LovMaster", (string)null);
});
#pragma warning restore 612, 618
}
Expand Down
2 changes: 1 addition & 1 deletion src/FormBuilder.API/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
]
},
"DatabaseConfig": {
"ConnectionString": "Host=localhost; Port=5432; Database=FormBuilderDB; Username=postgres; Password=postgres"
"ConnectionString": "Data Source=.\\SQLEXPRESS; Database=FormBuilderDB; Trusted_Connection=true; TrustServerCertificate=true;"
}
}
3 changes: 2 additions & 1 deletion src/FormBuilder/Components/FormField.razor
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
Name="@dateField.Name"
@bind-Value="dateField.Value"
Placeholder="@dateField.Placeholder"
ReadOnly="Disabled"/>
ReadOnly="Disabled">
</RadzenDatePicker>
break;
}
</ChildContent>
Expand Down

0 comments on commit d8fc7ef

Please sign in to comment.