Entity framework code first inheritance table per type problem

hello
i am using ODP.NET version 11.2.0.3.20. i am trying to get entity framework code first to work. one problem i have encountered is with inheritance. i have a "table per type" inheritance scenario. i have 3 tables involved. the base table is called "S_PERIOD" which maps to the base "Period" class. i have a derived table called "S_SEASON_QUARTER" that maps to the derived "Quarter" class. And I have another derived table called "S_SEASON_PRICE_PERIOD" that maps to the derived "PriceBreak" class. for testing purposes i am trying to load all records. the problem is that every class instance ends up being of type "Quarter", which is incorrect. for whatever reason the provider thinks that every "S_PERIOD" record has a corresponding "S_SEASON_QUARTER" record. i took a look at the generated SQL and posted it down below. looking at this SQL it's clear to me why every object ends up being of type "Quarter". It looks like the provider is checking the "C2" field to determine the concrete type to instantiate. the problem however is that the "C2" field value provided by each derived table is ALWAYS equal to "1", which is a problem since this will result in the "case" statement always hitting the second "when" condition. does anyone have any idea how to fix this? thank you
SELECT
CASE WHEN (( NOT (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL))) AND ( NOT (("Project2"."C2" = 1) AND ("Project2"."C2" IS NOT NULL)))) THEN '0X' WHEN (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL)) THEN '0X0X' ELSE '0X1X' END AS "C1",
CAST( "Extent1"."PERIOD_ID" AS number(10,0)) AS "C2",
"Extent1"."START_DATE" AS "START_DATE",
"Extent1"."END_DATE" AS "END_DATE",
"Extent1"."NAME" AS "NAME",
"Extent1"."TYPE_CODE" AS "TYPE_CODE",
CAST( "Extent1"."CREATE_USER_ID" AS number(10,0)) AS "C3",
"Extent1"."CREATE_DATE" AS "CREATE_DATE",
CAST( "Extent1"."MODIFY_USER_ID" AS number(10,0)) AS "C4",
"Extent1"."MODIFY_DATE" AS "MODIFY_DATE",
CASE WHEN (( NOT (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL))) AND ( NOT (("Project2"."C2" = 1) AND ("Project2"."C2" IS NOT NULL)))) THEN NULL WHEN (("Project1"."C2" = 1) AND ("Project1"."C2" IS NOT NULL)) THEN "Project1"."QUARTER_NAME" END AS "C5"
FROM "DBO_SPACE_DEV"."S_PERIOD" "Extent1"
LEFT OUTER JOIN (SELECT
     "Extent2"."QUARTER_NAME" AS "QUARTER_NAME",
     CAST( "Extent2"."QUARTER_ID" AS number(10,0)) AS "C1",
     1 AS "C2"
     FROM "DBO_SPACE_DEV"."S_SEASON_QUARTER" "Extent2" ) "Project1" ON ( CAST( "Extent1"."PERIOD_ID" AS number(10,0))) = "Project1"."C1"
LEFT OUTER JOIN (SELECT
     CAST( "Extent3"."PRICE_PERIOD_ID" AS number(10,0)) AS "C1",
     1 AS "C2"
     FROM "DBO_SPACE_DEV"."S_SEASON_PRICE_PERIOD" "Extent3" ) "Project2" ON ( CAST( "Extent1"."PERIOD_ID" AS number(10,0))) = "Project2"."C1"
Edited by: 997830 on Apr 3, 2013 8:40 AM

An update:
I tried again following this example to the letter:
Using NuGet to Install and Configure Oracle Data Provider for .NET
This time I used a console application as described in the example. Yes, I rebuilt the project after the NuGet install.
I made the appropriate mods to App.config. I get the same error message as with the MVC example above.
Does the ODP.Net driver really work with EF? If so, can anyone provide me with a working sample project?

Similar Messages

  • Entity Framework - Code First - Migration - How to access SQL Server and Oracle using the same context?

    Hello,
    I use Entity Framework code first approach.
    My project is working fine with SQL Server. But, I want to access Oracle too. I want to switch SQL Server and Oracle in run time.
    I am able to access Oracle using "Oracle.ManagedDataAccess.EntityFramework.dl" in a new project.
    But, Is this possible to access SQL Server and Oracle in the same project.
    Thanks,
    Murugan

    This should be possible with a Code-First workflow.  In Code-First the database mapping layer is generated at runtime.
    David
    David http://blogs.msdn.com/b/dbrowne/

  • Boolean types with entity framework code first and oracle provider

    Working in a application that has to work in oracle and sqlServer. In SqlServer we have used "Bit" to store booleans and in oracle number(1).
    Have check other threads in this forum, but didnt find any that fix my problem, sorry if this may have been discused before.
    We have created a code first model were we find few bool properties mapped to database fields.
    for example:
    public partial class ZPruebaBooleano
    public int Numero { get; set; }
    public bool Booleano { get; set; }
    Mapped as:
    this.ToTable("ZPRUEBABOOLEANO", schema);
    this.HasKey<int>(t => t.Numero);
    this.Property(t => t.Numero).HasColumnName("NUMERO");
    this.Property(t => t.Booleano).HasColumnName("BOOLEANO");
    Also, sw added to the application configuration file (for simplicity we have test it without the use of any additional dll):
    <oracle.dataaccess.client>
    <settings>
    <add name="bool" value="edmmapping number(1,0)" />
    <add name="byte" value="edmmapping number(3,0)" />
    <add name="int16" value="edmmapping number(4,0)" />
    <add name="int32" value="edmmapping number(9,0)" />
    <add name="int64" value="edmmapping number(18,0)" />
    </settings>
    </oracle.dataaccess.client>
    I am confident that the provider factory read it when creating the model, because it provokes an exception if i add an invalid entry in any of the type names mapped in the file.
    As i have find in other forums, this should work. But now i am not sure if should work always, including code first.
    I have this exception when i excecute the code (translated from spanish, sorry for any mistake):
    Type 'Edm.Boolean[Nullable=False,DefaultValue=]' from 'Booleano' to type'PruebaBooleanos.ZPruebaBooleano' is not compatyble with 'OracleEFProvider.number[Nullable=False,DefaultValue=,Precision=38,Scale=0]'
    Its funy that says Precision=38. The database is Number(1), i am sure about that, in fact this is the script:
    CREATE TABLE ZPRUEBABOOLEANO
    NUMERO NUMBER(15),
    BOOLEANO NUMBER(1)
    Also, i find it interesting that i was having this mistake even when i was not informing the table i was maping, like if the oracle provider didnt even check if the column was number(anything). Right now is well maped, table and schema.
    I have test to create an integer property wrapped by the boolean one, as we can see in this code.
    namespace PruebaBooleanos
    public partial class ZPruebaBooleano
    public int Numero { get; set; }
    public bool Booleano
    get
    return iBooleano == 1 ? true : false;
    set
    iBooleano = value ? 1 : 0;
    public int iBooleano { get; set; }
    in this last case i ignored the boolean and mapped the integer.
    That worked ok in oracle. But added 2 problems:
    1. It fails in SqlServer, because in sql server is bit
    2. Cant query the entity model using the boolean property as it is not maped to Database.
    I could change the bit field in SqlServer to Number.
    But i would like to keep bit in sqlserver and number(1) in oracle.
    Anyone had a similar problem?
    I am open to any ideas, thanks !!!
    libo

    It's cool. :)
    Sure. I can upload an EDMX file that works against my database if you want to look at it. The relevant parts are probably much like you'd expect. I've removed some columns from this version to make it easier to read.
    From the SSDL:
            <EntityType Name="PARAMETER">
              <Key>
                <PropertyRef Name="PARAMETER_CD" />
              </Key>
              <Property Name="PARAMETER_CD" Type="number" Nullable="false" Precision="4" />
              <Property Name="PARAMETER_ACTIVE_INDR" Type="number" Nullable="false" Precision="1" />
            </EntityType>From the CSDL:
    <EntityType Name="PARAMETER">
              <Key>
                <PropertyRef Name="PARAMETER_CD" />
              </Key>
              <Property Type="Int16" Name="PARAMETER_CD" Nullable="false" />
              <Property Type="Boolean" Name="PARAMETER_ACTIVE_INDR" Nullable="false" />
            </EntityType>From the C-S mapping:
    <EntitySetMapping Name="PARAMETER">
                <EntityTypeMapping TypeName="Model.PARAMETER">
                  <MappingFragment StoreEntitySet="PARAMETER">
                    <ScalarProperty Name="PARAMETER_ACTIVE_INDR" ColumnName="PARAMETER_ACTIVE_INDR" />
                    <ScalarProperty Name="PARAMETER_CD" ColumnName="PARAMETER_CD" />
                  </MappingFragment>
                </EntityTypeMapping>
              </EntitySetMapping>Also worth noting that the EDMX mapper probably won't set the provider and token correctly:
    <Schema Namespace="Model.Store" Alias="Self" Provider="Oracle.DataAccess.Client" ProviderManifestToken="11.2" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">Full version is available at http://www.hiredgoons.ca/DataImport.edmx . This is an early development one so I make no apologies for not renaming columns to something readable. ;) It does work correctly as I've had it in testing (taking data from a 170MB excel file and putting it into Oracle using the model). It was created using DB First.
    When you have it load at runtime, you need the application configuration settings to map bool to number(1). If that's in app.config or web.config it'll pick it up. Probably worth noting that if you don't have the configuration setting and you load this, the model doesn't validate correctly. As soon as you try to create a DbContext from it, you get an immediate exception that number(1) doesn't map to boolean.
    Edited by: Tridus on Nov 21, 2012 3:37 PM

  • EF6 Code first inheritance from relationship

    I need to create a TPH inheritance on an existing database using EF6 and Code first
    Table Person
    PersonId (Key)
    PersonName
    PersonTypeId (FK)
    Table PersonType:
    PersonTypeId (Key)
    Description
    Category
    The field PersonTypeId is the discriminator for the employees and managers, and the classes that I use are:
    class Person
    public string PersonId {get; set;}
    public string  TypeId {get; set;}
    public PersonType Type {get; set}
    class Employee : Person
    class Manager : Person
    I use the fluent API to create the relationship between Person and
    PersonType like that:
    HasOptional(e => e.Type).WithMany().HasForeignKey(f => f.TypeId);
    and it works as expected.
    Now, I need to Map the inherintance like that:
     m.Requires("Type.Category").HasValue("EMP");
    but it doesn't work because I receive an exception saying that the discriminator field doesn't exist.
    Any suggestions??

    I try to explain me better
    m.Requires("PersonTypeId").HasValue("EMP")
    It's ok, but it's not what I need 
    The mapping discriminator is not the PersonTypeId but the Category field that is in the class(or table) referred by PersonTypeId
    I have more than one values of PersonTypeId that has the same category (employee).
    If I choose your solution I need that PersonTypeId has more than one value
    Like that:
    m.Requires("PersonTypeId").HasValue("1").HasValue("2");
    but I know that there isn't this possiblity to have more than 1 value for a discriminator. Is it true?
    I try to explain me better
    m.Requires("PersonTypeId").HasValue("EMP")
    It's ok, but it's not what I need 
    The mapping discriminator is not the PersonTypeId but the Category field that is in the class(or table) referred by PersonTypeId
    I have more than one values of PersonTypeId that has the same category (employee).
    If I choose your solution I need that PersonTypeId has more than one value
    Like that:
    m.Requires("PersonTypeId").HasValue("1").HasValue("2");
    but I know that there isn't this possiblity to have more than 1 value for a discriminator. Is it true?

  • How to create ForeignKey reference to code-first identity tables.

    Hi,
    I'm developing a web application using MVC 5, EntityFramework 6 with a Code-First approach.
    I have successfully created my tables dbo.AspNetRoles, dbo.AspNetUsers... etc, also I have created some custom tables for example a table that must have a relationship between the menus presented and the role of the authenticated user. What I want to add
    to my model is a property like this:
    [ForeignKey]public virtual AspNetRoles Roles { get; set; }
    But of course I have not an AspNetRoles class, because the framework auto generates the tables only in the SQL database, so my question is, I have to manually create this classes? How can I link them to the database tables, I think the issue may be deeper.
    If I can't do this maybe I should go back to SQL manual queries.
    Thanks!

    Hello Morral,
    >> What I want to add to my model is a property like this:
    If you have a separate model to store your own business model, what you have written should be almost ok, however, please take care the [ForeignKey] attribute is usually used to markup a property as an integer property to specify it as a foreign key:
    public virtual int RoleID { get; set; } [ForeignKey("RoleID")] 
    public virtual AspNetRoles Roles { get; set; }
    Or it would generated a combinatorial name.
    >> But of course I have not an AspNetRoles class, because the framework auto generates the tables only in the SQL database, so my question is, I have to manually create this classes?
    From your description, the AspNetRoles class seems to be a system class which is not exposed to user. If so, these classes already exists, you do not need to create them again.
    I notice that you are working with the MVC project, you could also ask this issue to the MVC forum:
    http://forums.asp.net/1146.aspx
    There are MVC experts will help you.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • "Object reference not set to an instance of an object." in Visual Studio 2012 Entity Framework Model-First

    Hello
    We're trying to use a Model-First with Entity Framework in Visual Studio, targeting an Oracle XE 11g installation.
    No matter from what angle we're approaching the issue, we always end up with an "Object reference not set to an instance of an object" in Visual Studio:
    First way:
    - Add new ADO.NET Entity Framework Model to a .NET Framework 4.5 project
    - Empty model
    - Add some entities and associations
    - Set Database Generation Workflow to "Generate Oracle Via T4 (TPT).xaml"
    - Set DDL Generation Template to "SSDLToOracle.tt"
    - Generate Database From Model
    - VS asks for DB connection ==> Click "New Connection"
    - Enter the connection properties to the Oracle XE database. "Test Connection" tells me the connection is okay.
    - Click OK. Visual Studio shows the following error message:
    (here's the image if it's not visible: https://dl.dropboxusercontent.com/u/35614983/vs2012_oracle_ef_error.png)
    We also tried to generate the model in VS2010 and then manually transform it to an EF5 / VS2012 model. At the "Generate Database from Model" step, the same error appeared.
    We also tried to generate the model from database (Database-First approach). Same error.
    My configuration:
    - Windows 7 Ultimate 64-bit
    - Installed Oracle client: ODTwithODAC1120320_32bit.zip, so the version is 11.2.0.3.20
    - Visual Studio 2012 Update 3 (11.0.60610.01)
    Thanks for any hints!
    EDIT: I just read that ODP.NET doesn't seem to support Entity Framework 5, so I tried a new project with Entity Framework 4.1, but I get the same errors.
    EDIT 2: On a 32-bit Windows 7 virtual machine, everything works fine. Seems the problem is only there on my 64-bit Windows 7 machine.

    Sorry for the delay on this one. Let me know if you are still seeing this and I will see if we can get more diagnostic info somehow.
    That error is basically an exception fault. It means a bug or a misconfiguration of Oracle Developer Tools. Can you try to reinstall ODT and see if you notice any unusual errors during install.. and see if a reinstall fixes the problem?

  • Enity Framework Code First

    I am trying to get the latest provider for EF to work in Code First environment. I got no issue if I build the model through the wizard by pointing it to my DB, but in Code FIrst I cannot connect. Here are my two connection strings:
              <add name="OracleHR"
                   connectionString="DATA SOURCE=localhost:1521/XE;PASSWORD=****;PERSIST SECURITY INFO=True;USER ID=HR;"
                   providerName="Oracle.DataAccess.Client" />
              <add name="Entities"
                   connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=localhost:1521/XE;PASSWORD=****;PERSIST SECURITY INFO=True;USER ID=HR&quot;" providerName="System.Data.EntityClient" />
    My second connection string works fine and I can get the data, but first one fails with "Network Error"
    Suggestions are appreciated.
    Thanks.

    user13252411 wrote:
    When do you plan to support Code First?We haven't announced a date for that yet. Subscribe to our mail list and keep an eye on our .NET Developer Center for updates.

  • Entity Framework doesn't create the database in SQL Server Management 2012, instead it just creates in (localdb)\v11.0 How to fix it?

    Hi, I'm Begginer in Entity Framework. Then I'm having some problems.
    I created my entities and I give Save Changes. (Ok)
    Then, I Tried to Connect with the database through Server Explorer, if I use the instance of the SQL Server Management Studio 2012(PC-PAULO\INSTANCIAPJ) as Server Name, the database doesn't appears but, if I use the the instance (localdb)\v11.0 the dabase
    appears.
    How to change the save to the SQL Server Management Studio 2012, I don't know where this (localDB)\v11.0 saves.
    Help-me Thank you :D

    Hello PauloJos,
    The code should be ok and it is really strange that the database is only created into the local database in your machine. I am wondering if it is related with the machine environment, could you please have a try with below demo on your machine which works
    on my side and if it is possible, please have a try to run your application on other machines to see if it works:
    class Program
    static void Main(string[] args)
    #region https://social.msdn.microsoft.com/Forums/en-US/00eff3c4-2336-4807-9212-e6f2a6c8812e/entity-framework-doesnt-create-the-database-in-sql-server-management-2012-instead-it-just-creates?forum=adodotnetentityframework
    using (CFDbContext db = new CFDbContext())
    db.Database.CreateIfNotExists();
    #endregion
    public class CFDbContext : DbContext
    public CFDbContext() : base("UltraFoda3") { }
    public DbSet<TestOne> TestOnes { get; set; }
    public class TestOne
    public int ID { get; set; }
    public string Name { get; set; }
    Config file is similar:
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </configSections>
    <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
    <parameters>
    <parameter value="v11.0" />
    </parameters>
    </defaultConnectionFactory>
    <providers>
    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
    </entityFramework>
    <connectionStrings>
    <add name="UltraFoda3" connectionString="Data Source=YourServer;Initial Catalog=UltraFoda3;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
    </connectionStrings>
    </configuration>
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Calling Oracle stored procedure with out param of user define type from Entity Framework 5 with code first

    Guys i am using Entity Framework 5 code first (I am not using edmx) with Oracle and all works good, Now i am trying to get data from stored procedure which is under package but stored procedure have out param which is user define type, Now my question is
    how i will call stored procedure from entity framework
    Thanks in advance.

    I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
    If you think you are going to get existing MS Stored Procedures  or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
    coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
    You could use the EF backdoor, call Oracle Command object and use the Packages,  if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
    That's about your best shot.
    http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx

  • Call StoreProcedure in Code First Entity FrameWork

    i want to call store procedure by Code First Entity Framework and language:c# . it return one value of string.can i help me?

    hi,
    try this link :
    http://stackoverflow.com/questions/3500509/calling-user-defined-functions-in-entity-framework-4
    this also can help
    http://blogs.msdn.com/b/efdesign/archive/2011/01/21/table-valued-function-support.aspx
    and this:
    http://www.entityframeworktutorial.net/EntityFramework5/table-valued-function-in-entity-framework5.aspx

  • Entity Framework - Execute Stored Procedures With Table Valued Patameter

    How to pass a table valued parameter to a stored procedure in Entity Framework using ExecuteSqlCommand or SqlQuery method?
    Following is my code - 
    DataTable dataTable=new DataTable();
    dataTable.Columns.Add("col1", typeof(int));
    dataTable.Columns.Add("col2", typeof(bool));
    dbContext.Database.ExecuteSqlCommand("exec stored_proc @tvp",
                            new SqlParameter() { SqlDbType = SqlDbType.Structured, ParameterName = "@tvp", Value = dataTable }
    This throws an exception saying 'The table type parameter '@tvp' must have a valid type name.'

    You must set the TypeName property of the SqlParameter to the name of your table type that you have defined in the database:
    SqlParameter param = new SqlParameter();
    param.SqlDbType = SqlDbType.Structured;
    param.ParameterName = "@tvp";
    param.TypeName = "dbo.YourTableType";
    param.Value = dataTable;
    dbContext.Database.ExecuteSqlCommand("exec stored_proc @tvp", param);
    Of course you must define the table type in the database first:
    CREATE TYPE dbo.YourTableType AS TABLE
    ( col1 int, col1 bit )
    Please remember to the following page on MSDN for more information:
    https://msdn.microsoft.com/en-us/library/bb675163(v=vs.110).aspx
    Hope that helps.
    Please also remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

  • Entity Framework Generated SQL for paging or using Linq skip take causes full table scans.

    The slq genreated creates queries that cause a full table scan for pagination.  Is there any way to fix this?
    I am using
    ODP.NET ODTwithODAC1120320_32bit
    ASP.NET 4.5
    EF 5
    Oracle 11gR2
    This table has 2 million records. The further into the records you page the longer it takes.
    LINQ
    var cnt = (from errorLog in ctx.ERRORLOGANDSERVICELOG_VIEW
                        select errorLog).Count();
                    var query = (from errorLog in ctx.ERRORLOGANDSERVICELOG_VIEW
                                 orderby errorLog.ERR_LOG_ID
                                 select errorLog).Skip(cnt-10).Take(10).ToList();
    Here is the query & execution plans.
    SELECT *
    FROM   (SELECT "Extent1"."ERR_LOG_ID"  AS "ERR_LOG_ID",
                   "Extent1"."SRV_LOG_ID"  AS "SRV_LOG_ID",
                   "Extent1"."TS"          AS "TS",
                   "Extent1"."MSG"         AS "MSG",
                   "Extent1"."STACK_TRACE" AS "STACK_TRACE",
                   "Extent1"."MTD_NM"      AS "MTD_NM",
                   "Extent1"."PRM"         AS "PRM",
                   "Extent1"."INSN_ID"     AS "INSN_ID",
                   "Extent1"."TS_1"        AS "TS_1",
                   "Extent1"."LOG_ETRY"    AS "LOG_ETRY"
            FROM   (SELECT "Extent1"."ERR_LOG_ID"                                  AS "ERR_LOG_ID",
                           "Extent1"."SRV_LOG_ID"                                  AS "SRV_LOG_ID",
                           "Extent1"."TS"                                          AS "TS",
                           "Extent1"."MSG"                                         AS "MSG",
                           "Extent1"."STACK_TRACE"                                 AS "STACK_TRACE",
                           "Extent1"."MTD_NM"                                      AS "MTD_NM",
                           "Extent1"."PRM"                                         AS "PRM",
                           "Extent1"."INSN_ID"                                     AS "INSN_ID",
                           "Extent1"."TS_1"                                        AS "TS_1",
                           "Extent1"."LOG_ETRY"                                    AS "LOG_ETRY",
                           row_number() OVER (ORDER BY "Extent1"."ERR_LOG_ID" ASC) AS "row_number"
                    FROM   (SELECT "ERRORLOGANDSERVICELOG_VIEW"."ERR_LOG_ID"  AS "ERR_LOG_ID",
                                   "ERRORLOGANDSERVICELOG_VIEW"."SRV_LOG_ID"  AS "SRV_LOG_ID",
                                   "ERRORLOGANDSERVICELOG_VIEW"."TS"          AS "TS",
                                   "ERRORLOGANDSERVICELOG_VIEW"."MSG"         AS "MSG",
                                   "ERRORLOGANDSERVICELOG_VIEW"."STACK_TRACE" AS "STACK_TRACE",
                                   "ERRORLOGANDSERVICELOG_VIEW"."MTD_NM"      AS "MTD_NM",
                                   "ERRORLOGANDSERVICELOG_VIEW"."PRM"         AS "PRM",
                                   "ERRORLOGANDSERVICELOG_VIEW"."INSN_ID"     AS "INSN_ID",
                                   "ERRORLOGANDSERVICELOG_VIEW"."TS_1"        AS "TS_1",
                                   "ERRORLOGANDSERVICELOG_VIEW"."LOG_ETRY"    AS "LOG_ETRY"
                            FROM   "IDS_CORE"."ERRORLOGANDSERVICELOG_VIEW" "ERRORLOGANDSERVICELOG_VIEW") "Extent1") "Extent1"
            WHERE  ("Extent1"."row_number" > 1933849)
            ORDER  BY "Extent1"."ERR_LOG_ID" ASC)
    WHERE  (ROWNUM <= (10))
    | Id  | Operation              | Name                   | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT       |                        |    10 | 31750 |       |   821K  (1)| 02:44:15 |
    |*  1 |  COUNT STOPKEY         |                        |       |       |       |            |          |
    |   2 |   VIEW                 |                        |  1561K|  4728M|       |   821K  (1)| 02:44:15 |
    |*  3 |    VIEW                |                        |  1561K|  4748M|       |   821K  (1)| 02:44:15 |
    |   4 |     WINDOW SORT        |                        |  1561K|  3154M|  4066M|   821K  (1)| 02:44:15 |
    |*  5 |      HASH JOIN OUTER   |                        |  1561K|  3154M|       |   130K  (1)| 00:26:09 |
    |   6 |       TABLE ACCESS FULL| IDS_SERVICES_LOG       |  1047 | 52350 |       |     5   (0)| 00:00:01 |
    |   7 |       TABLE ACCESS FULL| IDS_SERVICES_ERROR_LOG |  1561K|  3080M|       |   130K  (1)| 00:26:08 |
    Predicate Information (identified by operation id):
       1 - filter(ROWNUM<=10)
       3 - filter("Extent1"."row_number">1933849)
       5 - access("T1"."SRV_LOG_ID"(+)="T2"."SRV_LOG_ID")

    I did try a sample from stack overflow that would apply it to all string types, but I didn't see any query results differences.  Please note, I am having the problem without any order with or where statements. Of course the skip take generates them.  Please advise how I would implement the EntityFunctions.AsNonUnicode method with this Linq query.
    LINQ
    var cnt = (from errorLog in ctx.ERRORLOGANDSERVICELOG_VIEW
                        select errorLog).Count();
                    var query = (from errorLog in ctx.ERRORLOGANDSERVICELOG_VIEW
                                 orderby errorLog.ERR_LOG_ID
                                 select errorLog).Skip(cnt-10).Take(10).ToList();
    This is what I inserted into my model to hopefully fix it.  FROM:c# - EF Code First - Globally set varchar mapping over nvarchar - Stack Overflow
    /// <summary>
    /// Change the "default" of all string properties for a given entity to varchar instead of nvarchar.
    /// </summary>
    /// <param name="modelBuilder"></param>
    /// <param name="entityType"></param>
    protected void SetAllStringPropertiesAsNonUnicode(
       DbModelBuilder modelBuilder,
       Type entityType)
       var stringProperties = entityType.GetProperties().Where(
      c => c.PropertyType == typeof(string)
       && c.PropertyType.IsPublic
       && c.

  • Added 3 tables in Entity framework

    I added 3 tables to my EF: 2 tables for data and the third for connection between them (= 3 columns in this table, first ID as
    the primary key, and the second and the third are FK to the other two tables).
    But the problem is that the third table was added with just the first column (= ID).
    Why is that?

    Hello shirley111,
    >>But the problem is that the third table was added with just the first column (= ID).
    Could you please tell which approach you are using, code first, model first or database first? And how do you define these three tables? Please also share them with us. Currently, we cannot understand what exactly happens on your side.
    Here are some information about many to many relationship in Entity Framework which might be helpful(from your description, it seems that you are trying to make a * to * relationship):
    Configure Many-to-Many relationship using Code First Approach
    Entity Relationships
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Problem Entity framework and short types

    I am using the Entity Framework in Visual Studio to access a table in my oracle database. Problem is when selecting a record in runtime the following error shows up:
    Value was either too large or too small for an Int16
    This error originates when trying to access a table-field declared as number(5). The framework translates this in a short field. The max value for short is 32767, but the value in the table is 36001.
    Can I solve this?
    thanks.

    Yes, you need to change the mapping for that type to an int32. To do that you can add this to your configuration file:
    <oracle.dataaccess.client>
    <settings>
    <add name="int16" value="edmmapping number(4,0)" />
    <add name="int32" value="edmmapping number(9,0)" />
    </settings>
    </oracle.dataaccess.client>
    You should then update the model to get the new changes. Note that I've found that I have to change the types manually in the model, but after I do that once it works fine. Documentation is here: http://docs.oracle.com/cd/E11882_01/win.112/e18754/featLINQ.htm

  • EJB 3.0 Entity Bean Inheritance Table Mapping

    What I want to do (I think)...
    In a distilled example form...
    - class A defines field x
    - class B defines field y, extends A, inheriting field x
    - class C defines field z, extends A, inheriting field x
    - I want class B to map to tbl_b which has columns x, y
    - I want class C to map to tbl_c which has columns x, z
    What I **don't** want to do (I think)...
    - make a base table for class A that is joined to tbl_b and tbl_c
    - map class B and class C to a single table that has a discriminator column
    Questions...
    1) Is there a conceptual problem with what I want to do?
    2) Is there a way to do what I want to do? I've tried via annotations. Maybe via the XML mapping alternative to annotations?

    Thanks for the reply Simon.
    Just to re-word what I want to do... I want to use a single table **for each lineage** in the hierarchy. In my original example that would be two tables.
    Table per class is what I tried but couldn't get to work - at least using annotations. I want to map some columns in the single table to base fields and some to derived fields.
    It seems that only 'single table with discriminator', or the 'join table' methods are sanctioned ways to handle an inheritance hierarchy.
    I didn't yet try using the XML method. I might be able to use the single table method by mapping base class properties as if they were derived class properties. This approach would work with a native Hibernate mapping XML.
    Back to the conceptual question. Is there a reason why I shouldn't do what I want here?
    What I'm trying to avoid...
    1) joining tables for performance issues
    2) having one table with columns that only make sense for certain records - ugly and potentially database storage waste.

Maybe you are looking for

  • Are there any workarounds for multiple PDF files created for a single Word 2011 document?

    I am running... Mac OS X Version 10.6.8 Word for Mac 2011 Adobe Acrobat X Version 10.1.0 I am working with 100 plus page Word documents that go back and forth between portrait and landscape layouts. When I attempt to create an Acrobat PDF document (o

  • How to read a flat file into a report?

    The file format is like below: Company Code : BUKRS(header) Posting Period :3(header) Then The items data is started as a table format. Line items in table format. If anybody knows the answer please share with me.

  • Boot camp "needs software updates"

    ok i got a MacBook (13-inch, Aluminum, Late 2008), that had worked nicely but this week i want to make a boot camp partition but the only thing i get its you have to update your software to use boot camp, i check all my updates and are ok, then i try

  • ACR Files not opening in CS6

    I recently purchased CS6 and loaded it to my desktop PC running Windows 7 and everyhing is fine. I recently purchased a new laptop and loaded a second copy to it (running Windows 8). When I process a RAW file and try to open it in PS6 about every 4th

  • External harddrive read only

    I have an iMac and am running Lion. I have an external harddrive which I've had for months. It's worked fine (uploading files to it and deleting files from it). But suddenly I can't do that. I've checked the Info (which tells me under "Sharing and Pe