SqlException: Invalid column name 'Konyha_Id'. (my first grid)

My table name:   Konyha
Columns:             Id int, Name nvarchar(100) ...
My grid:
@(Html.EJ().Grid<object>("FlatGrid")
    .Datasource((IEnumerable<object>)ViewBag.datasource)
    .AllowPaging()
)

Error:    SqlException: Invalid column name 'Konyha_Id'

Why? (Just for the first time...)
The system automatically assumes that the table has a Konyha_Id column?

Thank you for your answers!

3 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team December 7, 2017 03:53 PM UTC

Hi Attila, 

Thanks for contacting Syncfusion Support. 

We have checked your query but we need some additional information to find the cause of the issue. We have also prepared sample which can be downloaded from the below location. 


Could you please share us the following details to check your issue. 

1. Have you bind the field that doesn’t define on the data Source. 

2. Share us the issue reproducing sample or replicate the issue in the above sample and revert us back. 

3. Have you bind auto Generated columns to the Grid. 

4. Share us the stack trace of the issue. 

The provided information will be helpful to provided you the solution as early as possible. 

Regards, 

Farveen sulthana T 



AL Attila László December 16, 2017 02:12 PM UTC

Hi!

Konyha_Id problem ceased.

My new problems are:

1. In the _Layout.cshtml:
    @Styles.Render("~/Content/ej/web/material/ej.web.all.min.css")
    @*@Scripts.Render("~/Scripts/jquery-3.2.1.min.js")
    @Scripts.Render("~/Scripts/jsrender.min.js")
    @Scripts.Render("~/Scripts/ej/ej.web.all.min.js")*@
    @*@Scripts.Render("~/bundles/ejscripts")*@

    @*<link rel="stylesheet" rel='nofollow' href="http://cdn.syncfusion.com/15.4.0.17/js/web/flat-azure/ej.web.all.min.css" />*@
    <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script src="http://cdn.syncfusion.com/15.4.0.17/js/web/ej.web.all.min.js"></script>
    <script src="http://cdn.syncfusion.com/15.4.0.17/js/common/ej.unobtrusive.min.js"></script>

    As you can see, Scripts.Render not working, therefore I change that to cdn.
    The new project made by Syncfusion ASP.NET MVC Application template.

2. I want to use Areas, I made a new _Layout.cshtml in my area. I transposed the above code to its layout file.
    In that area, @Html.EJ().ScriptManager() isn't working.
    "Error CS1061 'HtmlHelper<dynamic>' does not contain a definition for 'EJ' ... "

3. So grid is working (almost) in the default _layout.
    I have the following datasource in the controller:
        public ActionResult Index()
        {
            var uzenetek = db.Uzenet.ToList();
            ViewBag.datasource = uzenetek;
            return View();
        }
    There is content in it (attached image: "uzenetek"). But the row doesn't appear in the grid. Header is OK.
    Grid in the Index.cshtml:
    <div class="col-md-8  col-md-offset-2">
    @(Html.EJ().Grid<object>("FlatGrid")
        .Datasource((IEnumerable<object>)ViewBag.datasource)
        .Columns(col =>
        {
            col.Field("Id").HeaderText("Azonosító").TextAlign(TextAlign.Right).Width(40).Add();
            col.Field("Cim").HeaderText("Cím").TextAlign(TextAlign.Left).Width(75).Add();
            col.Field("Szoveg").HeaderText("Szöveg").Width(200).Add();
        })
     )
    </div>

I would appreciate your help.
Thank you!

Attila László

Attachment: uzenetek_93536f67.rar


FS Farveen Sulthana Thameeztheen Basha Syncfusion Team December 18, 2017 03:24 PM UTC

Query #1 :- As you can see, Scripts.Render not working, therefore I change that to cdn. 
 
To resolve the error you have to ensure that Syncfusion dll’s and version for the corresponding dll has been referred properly in your we.config file. 

Query #2 :- Error CS1061 'HtmlHelper<dynamic>' does not contain a definition for 'EJ' " 
 
By default web.config file has been present for main project. So you have to ensure that you have separate web.config file under Area section.  

Query#3 :-  There is content in it (attached image: "uzenetek"). But the row doesn't appear in the grid. Header is OK. 

We suspected that the issue causes due to Circular Reference Error. The Circular Reference error during serializing the object of the Entity data Model can be resolved by Setting the ProxyCreationEnabled as false. 
 
Please refer the below link in which a similar problem had been discussed. 


 
 
Regards, 

Farveen sulthana T 


Loader.
Up arrow icon