简体   繁体   English

即使使用名称空间上的System.Data.Entity也无法识别HasDefaultSchema

[英]HasDefaultSchema is not recognized even with System.Data.Entity on the namespace

I want create a dbCotext and model according to my schema and view but I get the error: 我想根据自己的架构和视图创建dbCotext和模型,但出现错误:

public CarContext() : base(nameOrConnectionString: "LTtest") { }

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.HasDefaultSchema("wpv");   
    base.OnModelCreating(modelBuilder);
}
public DbSet<v_run_tt> v_run { get; set; } 

I need to write schema name, is there any other way? 我需要写架构名称,还有其他方法吗? I'm using PostgreSQL and entityframework 4 我正在使用PostgreSQL和EntityFramework 4

The HasDefaultSchema is only available in EFG 6+ ( https://msdn.microsoft.com/en-us/library/system.data.entity.dbmodelbuilder.hasdefaultschema(v=vs.113).aspx ). HasDefaultSchema仅在EFG 6+( https://msdn.microsoft.com/zh-cn/library/system.data.entity.dbmodelbuilder.hasdefaultschema ( v= HasDefaultSchema )中可用。

However, you can use the second parameter of toTable to specify the schema name. 但是,您可以使用toTable的第二个参数来指定架构名称。 toTable("tableName", "schemaName"); https://msdn.microsoft.com/en-us/library/gg679488(v=vs.113).aspx https://msdn.microsoft.com/en-us/library/gg679488(v=vs.113).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 命名空间“ System.Data.Entity”中不存在命名空间名称“ SqlServer” - Namespace name 'SqlServer' does not exist in the namespace 'System.Data.Entity 尽管安装了Entity Framework v6.1.3,仍无法访问System.Data.Entity命名空间? - Can't Access System.Data.Entity Namespace Despite Installing Entity Framework v6.1.3? 在一个文件的System.Data.Entity中找不到数据库名称空间 - Can't find Database namespace in System.Data.Entity in ONE file 在Team City上构建时,名称空间“System.Data.Entity”中不存在“验证” - 'Validation' does not exist in the namespace 'System.Data.Entity' when building on Team City 使用Linq + System.Data.Entity进行有效验证 - Effective Validation with Linq + System.Data.Entity 为什么C#项目的System.Data.Entity命名空间为空? - Why is my System.Data.Entity namespace blank for c# projects? EF 6对System.Data.Entity的依赖 - EF 6 dependency on System.Data.Entity MVC,Views和System.Data.Entity - MVC, Views and System.Data.Entity 基础架构在System.Data.Entity中不存在 - Infrastucture does not exist in System.Data.Entity Visual Studio 2012 MVC生成错误:名称空间“System.Data.Entity”中不存在类型或命名空间名称“Infrastructure” - Visual Studio 2012 MVC build error: The type or namespace name 'Infrastructure' does not exist in the namespace 'System.Data.Entity'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM