hhsung_work
hhsung 10 months ago
parent c007128dee
commit 82d36c2b63

@ -2,16 +2,19 @@
using System.Collections.Generic; using System.Collections.Generic;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory; using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace SmartAquaViewer.DataAnalisys namespace SmartAquaViewer.DataAnalisys
{ {
public class AppDbContext : DbContext public class AppDbContext : DbContext
{ {
//dotnet ef migrations add InitialCreate
//dotnet ef database update
//dotnet ef migrations add AddMultipleTables //dotnet tool install --global dotnet-ef
//dotnet ef database update //dotnet ef migrations add InitialCreate --project SmartAquaViewer
//dotnet ef database update --project SmartAquaViewer
//dotnet ef migrations add AddMultipleTables --project SmartAquaViewer
//dotnet ef database update --project SmartAquaViewer
@ -19,9 +22,14 @@ namespace SmartAquaViewer.DataAnalisys
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
// SQL Server 예시 (필요에 맞게 변경) // MySQL 연결 문자열 (일반적인 형태)
optionsBuilder.UseSqlServer( var connectionString = "Server=192.168.10.143;Port=3306;Database=smart_aqua;User=root;Password=znqk123!;";
"Server=localhost;Database=SmartAquaDB;Trusted_Connection=True;TrustServerCertificate=True;");
// MySQL Server Version 설정 (버전에 맞춰 변경)
var serverVersion = new MySqlServerVersion(new Version(8, 0, 36));
optionsBuilder.UseMySql(connectionString, serverVersion);
} }
} }
} }

@ -0,0 +1,80 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SmartAquaViewer.DataAnalisys;
#nullable disable
namespace SmartAquaViewer.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20250811050443_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("SmartAquaViewer.DataAnalisys.WaterQualityVO", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<double>("DO")
.HasColumnType("double");
b.Property<double>("ElectricalConductivity")
.HasColumnType("double");
b.Property<double>("FlowRate")
.HasColumnType("double");
b.Property<double>("ORP")
.HasColumnType("double");
b.Property<double>("PH")
.HasColumnType("double");
b.Property<double>("Salinity")
.HasColumnType("double");
b.Property<double>("TSS")
.HasColumnType("double");
b.Property<double>("Temperature")
.HasColumnType("double");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
b.Property<double>("TotalNitrogen")
.HasColumnType("double");
b.Property<double>("TotalPhosphorus")
.HasColumnType("double");
b.Property<double>("Turbidity")
.HasColumnType("double");
b.Property<double>("WaterLevel")
.HasColumnType("double");
b.Property<int>("WaterTankNum")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("WaterQuality");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,53 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SmartAquaViewer.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "WaterQuality",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
WaterTankNum = table.Column<int>(type: "int", nullable: false),
DO = table.Column<double>(type: "double", nullable: false),
PH = table.Column<double>(type: "double", nullable: false),
Temperature = table.Column<double>(type: "double", nullable: false),
WaterLevel = table.Column<double>(type: "double", nullable: false),
FlowRate = table.Column<double>(type: "double", nullable: false),
ElectricalConductivity = table.Column<double>(type: "double", nullable: false),
Turbidity = table.Column<double>(type: "double", nullable: false),
Salinity = table.Column<double>(type: "double", nullable: false),
ORP = table.Column<double>(type: "double", nullable: false),
TSS = table.Column<double>(type: "double", nullable: false),
TotalNitrogen = table.Column<double>(type: "double", nullable: false),
TotalPhosphorus = table.Column<double>(type: "double", nullable: false),
Timestamp = table.Column<DateTime>(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WaterQuality", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "WaterQuality");
}
}
}

@ -0,0 +1,77 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SmartAquaViewer.DataAnalisys;
#nullable disable
namespace SmartAquaViewer.Migrations
{
[DbContext(typeof(AppDbContext))]
partial class AppDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("SmartAquaViewer.DataAnalisys.WaterQualityVO", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<double>("DO")
.HasColumnType("double");
b.Property<double>("ElectricalConductivity")
.HasColumnType("double");
b.Property<double>("FlowRate")
.HasColumnType("double");
b.Property<double>("ORP")
.HasColumnType("double");
b.Property<double>("PH")
.HasColumnType("double");
b.Property<double>("Salinity")
.HasColumnType("double");
b.Property<double>("TSS")
.HasColumnType("double");
b.Property<double>("Temperature")
.HasColumnType("double");
b.Property<DateTime>("Timestamp")
.HasColumnType("datetime(6)");
b.Property<double>("TotalNitrogen")
.HasColumnType("double");
b.Property<double>("TotalPhosphorus")
.HasColumnType("double");
b.Property<double>("Turbidity")
.HasColumnType("double");
b.Property<double>("WaterLevel")
.HasColumnType("double");
b.Property<int>("WaterTankNum")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("WaterQuality");
});
#pragma warning restore 612, 618
}
}
}

@ -10,12 +10,17 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.2" /> <PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.8" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.8" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.8">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
</ItemGroup> </ItemGroup>
</Project> </Project>

Loading…
Cancel
Save