public class MyDbContext:DbContext
{
public DbSet<SysUserMod> SysUserMods { get; set; }
public MyDbContext(DbContextOptions<MyDbContext> options):base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ApplyConfiguration(new SysUserModMap());
}
}
public class SysUserModMap : IEntityTypeConfiguration<SysUserMod>
{
public void Configure(EntityTypeBuilder<SysUserMod> builder)
{
builder.HasKey(o => o.Id);
builder.Property(o => o.Id).IsRequired().HasMaxLength(128);
builder.Property(o => o.Name).HasMaxLength(128);
builder.ToTable(nameof(SysUserMod)+"_00");
}
}
public class SysUserMod
{
public string Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public int AgeGroup { get; set; }
}
internal class Program
{
public static readonly ILoggerFactory efLogger = LoggerFactory.Create(builder =>
{
builder.AddConsole();
});
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
var build = new DbContextOptionsBuilder<MyDbContext>()
.UseSqlServer("Data Source=localhost;Initial Catalog=ShardingCoreDBA;Integrated Security=True;TrustServerCertificate=True;")
.UseLoggerFactory(efLogger)
.Options;
var db=new MyDbContext(build);
//var x = new Object[] { "1", "2" };
var x = new List<Object> { "1", "2" };
var u=db.SysUserMods.Where(o => x.Contains(o.Id)).FirstOrDefault();
}
}
Include stack traces
Include verbose output
Include provider and version information
EF Core version: 8 Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer) Target framework: (e.g. .NET 8.0) Operating system: IDE: (e.g. Visual Studio 2022 17.4)
SQLSERVER 2012