Munjakis
Munjakis
CC#
Created by Core on 8/21/2024 in #help
✅ Class library is not loaded with the Main solution
I think there is a new solution file format(more readable)coming in .net 9
8 replies
CC#
Created by Core on 8/21/2024 in #help
✅ Class library is not loaded with the Main solution
@Core Maybe your class lib is targeting different version of dotnet than you project
8 replies
CC#
Created by Martixx on 8/20/2024 in #help
IsAuthenticated = false
No description
2 replies
CC#
Created by ThunderSpark91 on 8/16/2024 in #help
Entity Framework: Define a string computed Primary Key column in Data Annotations
Im not sure that i understood it well, but maybe something like this?
public class YourEntity
{
public int DEXID { get; set; }
public int GRID{ get; set; }
public bool BreedableState { get; set; }

// Computed composite key
public string CompKey => $"{DEXID}-{GRID}-{(BreedableState ? "t" : "f")}";
}

public class MyDbContext : DbContext
{
public DbSet<YourEntity> Persons { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Configure the composite key
modelBuilder.Entity<YourEntity>()
.HasKey(p => p.CompKey);
}
}
public class YourEntity
{
public int DEXID { get; set; }
public int GRID{ get; set; }
public bool BreedableState { get; set; }

// Computed composite key
public string CompKey => $"{DEXID}-{GRID}-{(BreedableState ? "t" : "f")}";
}

public class MyDbContext : DbContext
{
public DbSet<YourEntity> Persons { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Configure the composite key
modelBuilder.Entity<YourEntity>()
.HasKey(p => p.CompKey);
}
}
18 replies