Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 动态SQL错误(.NET Firebird实体框架)_C#_Asp.net_Asp.net Mvc_Entity Framework - Fatal编程技术网

C# 动态SQL错误(.NET Firebird实体框架)

C# 动态SQL错误(.NET Firebird实体框架),c#,asp.net,asp.net-mvc,entity-framework,C#,Asp.net,Asp.net Mvc,Entity Framework,在Visual Studio上执行解决方案时,我在控制器ProductoController.cs中遇到此错误 但是,如果我继续调试解决方案,至少避免3次相同的错误,我就可以显示数据库表的内容 我正在使用FirebirdSQL中的数据库。我检查了我的查询、模型和控制器。我检查了我的项目是否有元素_migrationhistorythe Unknown Table?,但没有 在我的ModelController.cs模型中,我有: namespace ConsultasEjecutivas.Mod

在Visual Studio上执行解决方案时,我在控制器ProductoController.cs中遇到此错误

但是,如果我继续调试解决方案,至少避免3次相同的错误,我就可以显示数据库表的内容

我正在使用FirebirdSQL中的数据库。我检查了我的查询、模型和控制器。我检查了我的项目是否有元素_migrationhistorythe Unknown Table?,但没有

在我的ModelController.cs模型中,我有:

namespace ConsultasEjecutivas.Models
{
    public class SAEContext : DbContext
    {
        public string TableName { get; set; }

        public SAEContext(string connectionString, string tableName)
            : base(new FbConnection(connectionString), true)
        {
            this.TableName = tableName;
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            var monDatabaseConfiguration = modelBuilder.Entity<Producto>();
            monDatabaseConfiguration.HasKey(x => x.ClaveArticulo);
            monDatabaseConfiguration.Property(x => x.ClaveArticulo).HasColumnName("CVE_ART");
            monDatabaseConfiguration.Property(x => x.Descripcion).HasColumnName("DESCR");
            monDatabaseConfiguration.Property(x => x.LineaProducto).HasColumnName("LIN_PROD");
            monDatabaseConfiguration.Property(x => x.UltimoCosto).HasColumnName("ULT_COSTO");
            monDatabaseConfiguration.ToTable(TableName);
        }

        public DbSet<Producto> Productos { get; set; }
    }
}
Producto.cs看起来是这样的:

namespace ConsultasEjecutivas.Models
{
    public class Producto
    {
            public string ClaveArticulo { get; set; }
            public string Descripcion { get; set; }
            public string LineaProducto { get; set; }
            public decimal UltimoCosto { get; set; }
    }
}

如果您能为我解决问题提供任何帮助,我将不胜感激。

转到“调试->异常”,并在“引发异常时中断”列中取消选中“公共语言运行时异常”。EF正在探测迁移历史记录表并捕获异常,但这是因为您选中了复选框VS breaks(对异常进行中断)。

将完整错误放入。如何在放入时避免问题3次。。你是不是正在跳到下一行?@MethodMan只有我点击继续debugging@Dnyanesh*第一次:{Dynamic SQL Error\r\nSQL Error code=-204\r\n表未知\r\n\u迁移历史记录\r\n第7行第29列}*第二次:{Dynamic SQL Error\r\nSQL Error code=-204\r\n表未知\r\n\u迁移历史记录\r\n第7行第29列}*第三次:{Dynamic SQL Error\r\nSQL Error code=-204\r\nTable unknown\r\nedmetadata\r\n在第5行第19列}转到Debug->Exceptions,并在引发异常列时取消选中Break中的公共语言运行时异常。EF正在探测迁移历史记录表并捕获异常,但这是因为您选中了异常上的复选框VS breaks。嗯,我的解决方案执行成功,但例如:如果我创建了一个新的解决方案,并且出现了错误,但我看不到它,因为我未选中公共语言运行时异常,此更改不会影响我的新项目吗?例如,执行一个新的解决方案,该解决方案显示问题的解决方案,但有错误。对不起,我的英语不好,这只会在抛出异常时关闭中断,而不会关闭未处理的异常。在绝大多数情况下,如果在异常到达代码之前处理了异常,则不应该关心是否引发了异常。调试器将在到达代码的异常上中断。请注意,默认情况下,此复选框未选中。你检查它的原因是什么?有帮助吗?你知道它是否有什么不同吗?它是在安装过程中默认选择的。
namespace ConsultasEjecutivas.Models
{
    public class Producto
    {
            public string ClaveArticulo { get; set; }
            public string Descripcion { get; set; }
            public string LineaProducto { get; set; }
            public decimal UltimoCosto { get; set; }
    }
}