C# EF DataContext,以编程方式设置架构名称
我目前正在将EF DataContext与以下类一起使用:C# EF DataContext,以编程方式设置架构名称,c#,.net,npgsql,ef-postgresql,C#,.net,Npgsql,Ef Postgresql,我目前正在将EF DataContext与以下类一起使用: [Table(Name = "schema.tablename")] public class Table { [Column(Name = "id", DbType = "serial", IsPrimaryKey = true, IsDbGenerated = true, CanBeNull = false)] public int ID { get; set; } ... } 有没有办法从web.c
[Table(Name = "schema.tablename")]
public class Table
{
[Column(Name = "id", DbType = "serial", IsPrimaryKey = true, IsDbGenerated = true, CanBeNull = false)]
public int ID { get; set; }
...
}
有没有办法从web.config动态分配架构名称?
我试过这个
public Table<Table> tables { get { return GetTable<Table("schema"); } }
DbContext
实现中的公共表{get{return GetTable:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema( "schema" );
}
在
DbContext
实现中:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema( "schema" );
}
DataContext-不是DbContext。我在DbContext上遇到了一些问题,所以我最终使用了DataContext。到目前为止,它工作得很好,除了thisDataContext-不是DbContext。我在DbContext上遇到了一些问题,所以我最终使用了DataContext。到目前为止,它工作得很好,除了这个