Revert "add lazy loading for entities"

This reverts commit ac6e4b51a9.
This commit is contained in:
hydrant
2019-05-13 18:05:25 +02:00
parent 33b98e3bbb
commit 27f6279429
23 changed files with 28 additions and 1308 deletions

View File

@@ -21,7 +21,7 @@ namespace ReallifeGamemode.Server.Entities
[ForeignKey("User")]
public int UserId { get; set; }
public virtual User User { get; set; }
public User User { get; set; }
public string Reason { get; set; }
public string BannedBy { get; set; }

View File

@@ -17,7 +17,7 @@ namespace ReallifeGamemode.Server.Entities
[ForeignKey("User")]
public int UserId { get; set; }
public virtual User User { get; set; }
public User User { get; set; }
public bool Gender { get; set; }
public byte Father { get; set; }

View File

@@ -17,7 +17,7 @@ namespace ReallifeGamemode.Server.Entities
[ForeignKey("User")]
public int UserId { get; set; }
public virtual User User { get; set; }
public User User { get; set; }
public bool Duty { get; set; }

View File

@@ -31,6 +31,6 @@ namespace ReallifeGamemode.Server.Entities
[ForeignKey("FactionId")]
public int? FactionId { get; set; }
public virtual Faction Faction { get; set; }
public Faction Faction { get; set; }
}
}

View File

@@ -20,7 +20,7 @@ namespace ReallifeGamemode.Server.Entities
[ForeignKey("Faction")]
public int FactionId { get; set; }
public virtual Faction Faction { get; set; }
public Faction Faction { get; set; }
public bool Gender { get; set; }

View File

@@ -20,7 +20,7 @@ namespace ReallifeGamemode.Server.Entities
public int Id { get; set; }
[ForeignKey("Faction")]
public int FactionId { get; set; }
public virtual Faction Faction { get; set; }
public Faction Faction { get; set; }
[StringLength(12)]
public string Bic { get; set; }
[StringLength(32)]

View File

@@ -13,7 +13,7 @@ namespace ReallifeGamemode.Server.Entities
public int FactionId { get; set; }
public virtual Faction Faction { get; set; }
public Faction Faction { get; set; }
public Faction GetFaction()
{

View File

@@ -15,7 +15,7 @@ namespace ReallifeGamemode.Server.Entities
{
[ForeignKey("Faction")]
public int? FactionId { get; set; }
public virtual Faction Faction { get; set; }
public Faction Faction { get; set; }
public Faction GetFaction()
{

View File

@@ -13,7 +13,7 @@ namespace ReallifeGamemode.Server.Entities
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public virtual Group Group { get; set; }
public Group Group { get; set; }
public int Balance { get; set; }
}

View File

@@ -10,7 +10,7 @@ namespace ReallifeGamemode.Server.Entities
{
public class GroupVehicle : ServerVehicle
{
public virtual Group Group { get; set; }
public Group Group { get; set; }
[ForeignKey("Group")]
public int? GroupId { get; set; }

View File

@@ -21,11 +21,11 @@ namespace ReallifeGamemode.Server.Entities.Logs
[ForeignKey("Victim")]
public int VictimId { get; set; }
public virtual User Victim { get; set; }
public User Victim { get; set; }
[ForeignKey("Killer")]
public int? KillerId { get; set; }
public virtual User Killer { get; set; }
public User Killer { get; set; }
public float VictimPositionX { get; set; }
public float VictimPositionY { get; set; }

View File

@@ -14,7 +14,7 @@ namespace ReallifeGamemode.Server.Entities
[ForeignKey("User")]
public int? UserId { get; set; }
public virtual User User { get; set; }
public User User { get; set; }
public string Caption { get; set; }
public string Content { get; set; }

View File

@@ -19,6 +19,7 @@ namespace ReallifeGamemode.Server.Entities
public class ShopVehicle : ServerVehicle
{
[ForeignKey("Shop")]
public int? ShopId { get; set; }
public int BusinessId { get; set; }
public int Price { get; set; }

View File

@@ -44,26 +44,24 @@ namespace ReallifeGamemode.Server.Entities
[ForeignKey("Character")]
public int? CharacterId { get; set; }
public virtual Character Character { get; set; }
public Character Character { get; set; }
[ForeignKey("Ban")]
public int? BanId { get; set; }
public virtual Ban Ban { get; set; }
public Ban Ban { get; set; }
public int? FactionId { get; set; }
public virtual Faction Faction { get; set; }
public Faction Faction { get; set; }
public bool FactionLeader { get; set; }
public int? FactionRankId { get; set; }
public virtual FactionRank FactionRank { get; set; }
public FactionRank FactionRank { get; set; }
public virtual Group Group { get; set; }
public Group Group { get; set; }
public GroupRank GroupRank { get; set; }
public virtual Job Job { get; set; }
public FactionRank GetFactionRank()
{
using (var dbContext = new DatabaseContext())

View File

@@ -23,7 +23,7 @@ namespace ReallifeGamemode.Server.Entities
public int Id { get; set; }
[ForeignKey("User")]
public int UserId { get; set; }
public virtual User User { get; set; }
public User User { get; set; }
[StringLength(12)]
public string Bic { get; set; }
[StringLength(32)]

View File

@@ -21,7 +21,7 @@ namespace ReallifeGamemode.Server.Entities
[ForeignKey("User")]
public int UserId { get; set; }
public virtual User User { get; set; }
public User User { get; set; }
public int Amount { get; set; }
public int Slot { get; set; }

View File

@@ -15,7 +15,7 @@ namespace ReallifeGamemode.Server.Entities
{
[ForeignKey("User")]
public int UserId { get; set; }
public virtual User User { get; set; }
public User User { get; set; }
public override string ToString()
{

View File

@@ -14,7 +14,7 @@ namespace ReallifeGamemode.Server.Entities
[ForeignKey("Vehicle")]
public int ServerVehicleId { get; set; }
public virtual ServerVehicle Vehicle { get; set; }
public ServerVehicle Vehicle { get; set; }
public int Slot { get; set; }
public int ModId { get; set; }

File diff suppressed because it is too large Load Diff

View File

@@ -1,90 +0,0 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace ReallifeGamemode.Migrations
{
public partial class Jobs : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "JobId",
table: "Users",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "JobId",
table: "ServerVehicles",
nullable: true);
migrationBuilder.CreateTable(
name: "Jobs",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Jobs", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Users_JobId",
table: "Users",
column: "JobId");
migrationBuilder.CreateIndex(
name: "IX_ServerVehicles_JobId",
table: "ServerVehicles",
column: "JobId");
migrationBuilder.AddForeignKey(
name: "FK_ServerVehicles_Jobs_JobId",
table: "ServerVehicles",
column: "JobId",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Users_Jobs_JobId",
table: "Users",
column: "JobId",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ServerVehicles_Jobs_JobId",
table: "ServerVehicles");
migrationBuilder.DropForeignKey(
name: "FK_Users_Jobs_JobId",
table: "Users");
migrationBuilder.DropTable(
name: "Jobs");
migrationBuilder.DropIndex(
name: "IX_Users_JobId",
table: "Users");
migrationBuilder.DropIndex(
name: "IX_ServerVehicles_JobId",
table: "ServerVehicles");
migrationBuilder.DropColumn(
name: "JobId",
table: "Users");
migrationBuilder.DropColumn(
name: "JobId",
table: "ServerVehicles");
}
}
}

View File

@@ -420,18 +420,6 @@ namespace ReallifeGamemode.Migrations
b.ToTable("Interiors");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Job", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.HasKey("Id");
b.ToTable("Jobs");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.BankAccountTransactionHistory", b =>
{
b.Property<int>("Id")
@@ -790,8 +778,6 @@ namespace ReallifeGamemode.Migrations
b.Property<int>("Handmoney");
b.Property<int?>("JobId");
b.Property<int>("LogUserId");
b.Property<string>("Name")
@@ -827,8 +813,6 @@ namespace ReallifeGamemode.Migrations
b.HasIndex("GroupId");
b.HasIndex("JobId");
b.ToTable("Users");
});
@@ -931,17 +915,6 @@ namespace ReallifeGamemode.Migrations
b.HasDiscriminator().HasValue("GroupVehicle");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.JobVehicle", b =>
{
b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle");
b.Property<int?>("JobId");
b.HasIndex("JobId");
b.HasDiscriminator().HasValue("JobVehicle");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedVehicle", b =>
{
b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle");
@@ -1077,10 +1050,6 @@ namespace ReallifeGamemode.Migrations
b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group")
.WithMany()
.HasForeignKey("GroupId");
b.HasOne("ReallifeGamemode.Server.Entities.Job", "Job")
.WithMany()
.HasForeignKey("JobId");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b =>
@@ -1121,13 +1090,6 @@ namespace ReallifeGamemode.Migrations
.HasForeignKey("GroupId");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.JobVehicle", b =>
{
b.HasOne("ReallifeGamemode.Server.Entities.Job", "Job")
.WithMany()
.HasForeignKey("JobId");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserVehicle", b =>
{
b.HasOne("ReallifeGamemode.Server.Entities.User", "User")

View File

@@ -12,9 +12,8 @@ namespace ReallifeGamemode.Server.Models
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.UseMySql("Host=localhost;Port=3306;Database=gtav-devdb;Username=gtav-dev;Password=Test123")
.UseLazyLoadingProxies();
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseMySql("Host=localhost;Port=3306;Database=gtav-devdb;Username=gtav-dev;Password=Test123");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
@@ -100,9 +99,5 @@ namespace ReallifeGamemode.Server.Models
public DbSet<Entities.Group> Groups { get; set; }
public DbSet<Entities.GroupBankAccount> GroupBankAccounts { get; set; }
public DbSet<Entities.GroupVehicle> GroupVehicles { get; set; }
// Jobs
public DbSet<Entities.Job> Jobs { get; set; }
public DbSet<Entities.JobVehicle> JobVehicles { get; set; }
}
}

View File

@@ -15,13 +15,12 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.4" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
</ItemGroup>
<ItemGroup Condition="'$(ConfigurationName)' != 'ServerBuild'">