0

i have the following problem :

I ve succesfully connected with an Oracle DB, and i ve constructed the model using the DB first approach provided by VS 2015 Community edition.

The problem starts when i try to add a controller / view with a declared model class, and data context class.

This is my db context class:

namespace ORACLETEST3.Models
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;

public partial class HREntities : DbContext
{
    public HREntities()
        : base("name=HREntities")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        //modelBuilder.Entity<>
        throw new UnintentionalCodeFirstException();
    }



    public virtual DbSet<BSNS_AREA> BSNS_AREA { get; set; }
    public virtual DbSet<MAIN> MAINs { get; set; }
    public virtual DbSet<OFFICE> OFFICEs { get; set; }
    public virtual DbSet<USER_TYPE> USER_TYPE { get; set; }
    public virtual DbSet<USR> USRs { get; set; }
}
}

When i try to add a view, i can -see- the data context class, but once i select one, i get an invocation error. Providing pics for reference :

enter image description here

If i dont select a data context class, i can add the view normally. If i do select a data context class, i get the following error:

enter image description here

This is what happens when i create an empty view, and try to bind the model:

@model ORACLETEST3.Models.USER_TYPE

@{
    ViewBag.Title = "View";
}

<h2>View</h2>

<div>
    <h4>USER_TYPE</h4>
    <hr />
    <dl class="dl-horizontal">
        <dt>
           @Html.DisplayNameFor(model => model.DESCR)
        </dt>

    <dd>
        @Html.DisplayFor(model => model.DESCR)
    </dd>

   </dl>
</div>
<p>
    @Html.ActionLink("Edit", "Edit", new { id = Model.ID }) |
    @Html.ActionLink("Back to List", "Index")
</p>

Is this some version mismatch thing?

onlyf
  • 767
  • 3
  • 19
  • 39
  • Typically when building a view you would bind to a view model type or maybe an entity type (ie. `BSNS_AREA` etc: maps to a single table) not the whole context. – Richard Nov 14 '17 at 12:03
  • You mean when i m selecting from DataContext class? or the @model? – onlyf Nov 14 '17 at 12:05
  • Scaffolding can be flakey. Have tried [these](https://stackoverflow.com/questions/23576294/application-cant-scaffold-items) and [these](https://stackoverflow.com/questions/23910162/scaffolding-controller-doesnt-work-with-visual-studio-2013-update-2)? – Steve Greene Nov 14 '17 at 15:20

0 Answers0