Answer the question
In order to leave comments, you need to log in
How to attach Entity Framework to Oracle DB?
Good day, Toaster!
I recently started studying Entity Framework (as part of studying MVC) and ran into a problem: I can’t pull data from a table. When trying to run an application that displays a list of books, the system writes: "Oracle.DataAccess.Client.OracleException: ORA-00942: user table or view does not exist."
And I do the following: I create a Book class in the Models folder of my MVC application.
namespace MVC4Test.Models
{
public class Book
{
public int Id { get; set; }
public string Name { get; set; }
public string Author { get; set; }
public decimal Price { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Web;
using System.Data.Entity;
namespace MVC4Test.Models
{
public class BookContext : DbContext
{
public DbSet<Book> BOOKS { get; set; }
//public DbSet<Purchase> Purchases { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC4Test.Models;
namespace MVC4Test.Controllers
{
public class HomeController : Controller
{
BookContext db = new BookContext();
public ActionResult Index()
{
IEnumerable<Book> books = db.BOOKS;
ViewBag.Books = books;
return View();
}
}
}
SELECT
CAST( "Extent1"."Id" AS number(10,0)) AS "C1",
"Extent1"."Name" AS "Name",
"Extent1"."Author" AS "Author",
"Extent1"."Price" AS "Price"
FROM "dbo"."Books" "Extent1"
Answer the question
In order to leave comments, you need to log in
1) Manual directly on the Oracle.com website.
2) How do you create connectionString? There must be heresy
res://*/Some.csdl|res://*/Some.ssdl|res://*/Some.msl;provider=System.Data.SqlClient;provider connection string="data source=MySQLServer;initial catalog=SomeDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question