first commit -push
This commit is contained in:
131
RobotNet.RobotManager/Data/Migrations/20250509040621_AddRobotDb.Designer.cs
generated
Normal file
131
RobotNet.RobotManager/Data/Migrations/20250509040621_AddRobotDb.Designer.cs
generated
Normal file
@@ -0,0 +1,131 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using RobotNet.RobotManager.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RobotNet.RobotManager.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(RobotEditorDbContext))]
|
||||
[Migration("20250509040621_AddRobotDb")]
|
||||
partial class AddRobotDb
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.Robot", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("Id");
|
||||
|
||||
b.Property<string>("ChargerNode")
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("ChargerNode");
|
||||
|
||||
b.Property<string>("HomeNode")
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("HomeNode");
|
||||
|
||||
b.Property<Guid>("MapId")
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("MapId");
|
||||
|
||||
b.Property<Guid>("ModelId")
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("ModelId");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("Name");
|
||||
|
||||
b.Property<string>("RobotId")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("RobotId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MapId");
|
||||
|
||||
b.ToTable("Robots");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.RobotModel", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("Id");
|
||||
|
||||
b.Property<int>("ImageHeight")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("ImageHeight");
|
||||
|
||||
b.Property<int>("ImageWidth")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("ImageWidth");
|
||||
|
||||
b.Property<double>("Length")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("Length");
|
||||
|
||||
b.Property<string>("ModelName")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("ModelName");
|
||||
|
||||
b.Property<int>("NavigationType")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("NavigationType");
|
||||
|
||||
b.Property<double>("OriginX")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("OriginX");
|
||||
|
||||
b.Property<double>("OriginY")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("OriginY");
|
||||
|
||||
b.Property<double>("Width")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("Width");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("RobotModels");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.Robot", b =>
|
||||
{
|
||||
b.HasOne("RobotNet.RobotManager.Data.RobotModel", "Model")
|
||||
.WithMany("Robots")
|
||||
.HasForeignKey("MapId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Model");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.RobotModel", b =>
|
||||
{
|
||||
b.Navigation("Robots");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RobotNet.RobotManager.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddRobotDb : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RobotModels",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
ModelName = table.Column<string>(type: "varchar(127)", nullable: false),
|
||||
OriginX = table.Column<double>(type: "float", nullable: false),
|
||||
OriginY = table.Column<double>(type: "float", nullable: false),
|
||||
Length = table.Column<double>(type: "float", nullable: false),
|
||||
Width = table.Column<double>(type: "float", nullable: false),
|
||||
ImageWidth = table.Column<int>(type: "int", nullable: false),
|
||||
ImageHeight = table.Column<int>(type: "int", nullable: false),
|
||||
NavigationType = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RobotModels", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Robots",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
RobotId = table.Column<string>(type: "varchar(127)", nullable: false),
|
||||
Name = table.Column<string>(type: "varchar(127)", nullable: false),
|
||||
ModelId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
MapId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
HomeNode = table.Column<string>(type: "varchar(127)", nullable: true),
|
||||
ChargerNode = table.Column<string>(type: "varchar(127)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Robots", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Robots_RobotModels_MapId",
|
||||
column: x => x.MapId,
|
||||
principalTable: "RobotModels",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Robots_MapId",
|
||||
table: "Robots",
|
||||
column: "MapId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Robots");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RobotModels");
|
||||
}
|
||||
}
|
||||
}
|
||||
131
RobotNet.RobotManager/Data/Migrations/20250509071716_fixRobotDb.Designer.cs
generated
Normal file
131
RobotNet.RobotManager/Data/Migrations/20250509071716_fixRobotDb.Designer.cs
generated
Normal file
@@ -0,0 +1,131 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using RobotNet.RobotManager.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RobotNet.RobotManager.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(RobotEditorDbContext))]
|
||||
[Migration("20250509071716_fixRobotDb")]
|
||||
partial class fixRobotDb
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.Robot", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("Id");
|
||||
|
||||
b.Property<string>("ChargerNode")
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("ChargerNode");
|
||||
|
||||
b.Property<string>("HomeNode")
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("HomeNode");
|
||||
|
||||
b.Property<Guid>("MapId")
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("MapId");
|
||||
|
||||
b.Property<Guid>("ModelId")
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("ModelId");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("Name");
|
||||
|
||||
b.Property<string>("RobotId")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("RobotId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ModelId");
|
||||
|
||||
b.ToTable("Robots");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.RobotModel", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("Id");
|
||||
|
||||
b.Property<int>("ImageHeight")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("ImageHeight");
|
||||
|
||||
b.Property<int>("ImageWidth")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("ImageWidth");
|
||||
|
||||
b.Property<double>("Length")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("Length");
|
||||
|
||||
b.Property<string>("ModelName")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("ModelName");
|
||||
|
||||
b.Property<int>("NavigationType")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("NavigationType");
|
||||
|
||||
b.Property<double>("OriginX")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("OriginX");
|
||||
|
||||
b.Property<double>("OriginY")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("OriginY");
|
||||
|
||||
b.Property<double>("Width")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("Width");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("RobotModels");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.Robot", b =>
|
||||
{
|
||||
b.HasOne("RobotNet.RobotManager.Data.RobotModel", "Model")
|
||||
.WithMany("Robots")
|
||||
.HasForeignKey("ModelId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Model");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.RobotModel", b =>
|
||||
{
|
||||
b.Navigation("Robots");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RobotNet.RobotManager.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class fixRobotDb : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Robots_RobotModels_MapId",
|
||||
table: "Robots");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Robots_MapId",
|
||||
table: "Robots");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Robots_ModelId",
|
||||
table: "Robots",
|
||||
column: "ModelId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Robots_RobotModels_ModelId",
|
||||
table: "Robots",
|
||||
column: "ModelId",
|
||||
principalTable: "RobotModels",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Robots_RobotModels_ModelId",
|
||||
table: "Robots");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Robots_ModelId",
|
||||
table: "Robots");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Robots_MapId",
|
||||
table: "Robots",
|
||||
column: "MapId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Robots_RobotModels_MapId",
|
||||
table: "Robots",
|
||||
column: "MapId",
|
||||
principalTable: "RobotModels",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using RobotNet.RobotManager.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RobotNet.RobotManager.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(RobotEditorDbContext))]
|
||||
partial class RobotEditorDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.Robot", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("Id");
|
||||
|
||||
b.Property<string>("ChargerNode")
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("ChargerNode");
|
||||
|
||||
b.Property<string>("HomeNode")
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("HomeNode");
|
||||
|
||||
b.Property<Guid>("MapId")
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("MapId");
|
||||
|
||||
b.Property<Guid>("ModelId")
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("ModelId");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("Name");
|
||||
|
||||
b.Property<string>("RobotId")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("RobotId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ModelId");
|
||||
|
||||
b.ToTable("Robots");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.RobotModel", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier")
|
||||
.HasColumnName("Id");
|
||||
|
||||
b.Property<int>("ImageHeight")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("ImageHeight");
|
||||
|
||||
b.Property<int>("ImageWidth")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("ImageWidth");
|
||||
|
||||
b.Property<double>("Length")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("Length");
|
||||
|
||||
b.Property<string>("ModelName")
|
||||
.IsRequired()
|
||||
.HasColumnType("varchar(127)")
|
||||
.HasColumnName("ModelName");
|
||||
|
||||
b.Property<int>("NavigationType")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("NavigationType");
|
||||
|
||||
b.Property<double>("OriginX")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("OriginX");
|
||||
|
||||
b.Property<double>("OriginY")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("OriginY");
|
||||
|
||||
b.Property<double>("Width")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("Width");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("RobotModels");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.Robot", b =>
|
||||
{
|
||||
b.HasOne("RobotNet.RobotManager.Data.RobotModel", "Model")
|
||||
.WithMany("Robots")
|
||||
.HasForeignKey("ModelId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Model");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RobotNet.RobotManager.Data.RobotModel", b =>
|
||||
{
|
||||
b.Navigation("Robots");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
40
RobotNet.RobotManager/Data/Robot.cs
Normal file
40
RobotNet.RobotManager/Data/Robot.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace RobotNet.RobotManager.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
[Table("Robots")]
|
||||
public class Robot
|
||||
{
|
||||
[Column("Id", TypeName = "uniqueidentifier")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Key]
|
||||
[Required]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[Column("RobotId", TypeName = "varchar(127)")]
|
||||
[Required]
|
||||
public string RobotId { get; set; } = string.Empty;
|
||||
|
||||
[Column("Name", TypeName = "varchar(127)")]
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column("ModelId", TypeName = "uniqueidentifier")]
|
||||
[Required]
|
||||
public Guid ModelId { get; set; }
|
||||
|
||||
[Column("MapId", TypeName = "uniqueidentifier")]
|
||||
[Required]
|
||||
public Guid MapId { get; set; }
|
||||
|
||||
[Column("HomeNode", TypeName = "varchar(127)")]
|
||||
public string HomeNode { get; set; }
|
||||
|
||||
[Column("ChargerNode", TypeName = "varchar(127)")]
|
||||
public string ChargerNode { get; set; }
|
||||
|
||||
public RobotModel Model { get; set; }
|
||||
}
|
||||
21
RobotNet.RobotManager/Data/RobotEditorDbContext.cs
Normal file
21
RobotNet.RobotManager/Data/RobotEditorDbContext.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace RobotNet.RobotManager.Data;
|
||||
|
||||
public class RobotEditorDbContext(DbContextOptions<RobotEditorDbContext> options) : DbContext(options)
|
||||
{
|
||||
public DbSet<Robot> Robots { get; private set; }
|
||||
public DbSet<RobotModel> RobotModels { get; private set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<RobotModel>()
|
||||
.HasMany(e => e.Robots)
|
||||
.WithOne(e => e.Model)
|
||||
.HasForeignKey(e => e.ModelId)
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
17
RobotNet.RobotManager/Data/RobotManagerDbExtensions.cs
Normal file
17
RobotNet.RobotManager/Data/RobotManagerDbExtensions.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace RobotNet.RobotManager.Data;
|
||||
|
||||
public static class RobotManagerDbExtensions
|
||||
{
|
||||
public static async Task SeedRobotManagerDbAsync(this IServiceProvider serviceProvider)
|
||||
{
|
||||
using var scope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope();
|
||||
|
||||
using var appDb = scope.ServiceProvider.GetRequiredService<RobotEditorDbContext>();
|
||||
|
||||
await appDb.Database.MigrateAsync();
|
||||
//await appDb.Database.EnsureCreatedAsync();
|
||||
await appDb.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
51
RobotNet.RobotManager/Data/RobotModel.cs
Normal file
51
RobotNet.RobotManager/Data/RobotModel.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using RobotNet.RobotShares.Enums;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace RobotNet.RobotManager.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
[Table("RobotModels")]
|
||||
public class RobotModel
|
||||
{
|
||||
[Column("Id", TypeName = "uniqueidentifier")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Key]
|
||||
[Required]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[Column("ModelName", TypeName = "varchar(127)")]
|
||||
[Required]
|
||||
public string ModelName { get; set; }
|
||||
|
||||
[Column("OriginX", TypeName = "float")]
|
||||
[Required]
|
||||
public double OriginX { get; set; }
|
||||
|
||||
[Column("OriginY", TypeName = "float")]
|
||||
[Required]
|
||||
public double OriginY { get; set; }
|
||||
|
||||
[Column("Length", TypeName = "float")]
|
||||
[Required]
|
||||
public double Length { get; set; }
|
||||
|
||||
[Column("Width", TypeName = "float")]
|
||||
[Required]
|
||||
public double Width { get; set; }
|
||||
|
||||
[Column("ImageWidth", TypeName = "int")]
|
||||
[Required]
|
||||
public int ImageWidth { get; set; }
|
||||
|
||||
[Column("ImageHeight", TypeName = "int")]
|
||||
[Required]
|
||||
public int ImageHeight { get; set; }
|
||||
|
||||
[Column("NavigationType", TypeName = "int")]
|
||||
[Required]
|
||||
public NavigationType NavigationType { get; set; }
|
||||
|
||||
public virtual ICollection<Robot> Robots { get; } = [];
|
||||
}
|
||||
Reference in New Issue
Block a user