Entity framework 5 model BindingLists instead of HashSets

When i create or update a model from database, the generated classes have as navigation properties a hasset.
I can not bind a hashSet to a datagrid so i change their type to a bindinglist. Please check the red area at the end of the code
Is there a template to create a bindinglist instead of hashSet?
// <auto-generated>
//    This code was generated from a template.
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
namespace Model
using System;
using System.ComponentModel;
using System.Collections.Generic;
publicpartialclassSalesOrders
public SalesOrders()
this.NumberOfTrucks = 1;
this.IsFromSap =false;
this.IsLocked =false;
this.IsCompleted =false;
this.Weight2 =newBindingList<Weight2>();
this.SalesOrdersVehicles =newBindingList<SalesOrdersVehicles>();
publicint
ID {get;set;
publicNullable<int>
SAPUID { get;set;
publicNullable<int>
PlantID { get;set;
publicstring
SalesOrderCode {get;set;
publicNullable<int>
CustomerID { get;set;
publicNullable<int>
ProductID { get;set;
publicNullable<int>
NumberOfTrucks { get;set;
publicstring
SalesOrderType {get;set;
publicstring
RefTransactionID {get;set;
publicstring
AdditionalField1 {get;set;
publicstring
AdditionalField2 {get;set;
publicstring
AdditionalField3 {get;set;
publicbool
IsFromSap {get;set;
publicbool
IsLocked {get;set;
publicbool
IsCompleted {get;set;
publicvirtualCustomers
Customers {get;set;
publicvirtualPlants
Plants {get;set;
publicvirtualProducts
Products {get;set;
publicvirtualBindingList<Weight2>
Weight2 { get;set;
publicvirtualBindingList<SalesOrdersVehicles>
SalesOrdersVehicles { get;set;

Hi iglezos,
When we're using default method to generate the model, there're two files with .tt extension files, one for DbContext class generation and the other for entities generations. The code you posted in the initial post is generated by the .tt file. So, if we
want to modify the code, we need to modify the .tt file and let it help us to generate the code again. I'm not clear about your meaning, what's the meaning of create completely different classes from the other template? I mean delete the default template and
use the "EF 5.x DbContext Generator" template to help us generate the entities. : )
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us

Similar Messages

  • "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?

  • 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.

  • Update the database structure from entity Framework Model

    Hello !
    I'm using VB.net , EF6 with SQL server 2008R2 database.
    This is the situation :
    I have created the application. Using wizard I have created the Entity model from an existing database.
    A client start using this application using this database on his computer.
    After some month , I made some modifications on the database and I have updated the model on my application .
    Now I have a new .exe file that has the new model from the new database.
    I put the new .exe file on the client computer.
    Now on his computer : The .exe file has the new database model , but the sql server database has the old structure.
    I want to know : Is possible to update the database structure from the entity model on application ?
    I want to add a command on application that can make ( if is possible ) this update , so the database become up to date according to entity model ?
    Thank you !

    Hello,
    From your description, it seems that you want to apply a migration for a database first approach, unfortunately, as far as I know, EF Migrations is a product targeted at Code First and doesn't support Database First operations. A workaround I know is to
    use update-scripts. If your database structure would be changed frequently, it is recommended to use the Code First approach which would have a better workaround for migrations, for details, you could refer to this
    video,
     and with the
    Entity Framework Power Tools, it is easy to create a code first based project form an existing database.
    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.

  • Self Reference Model Class - How to populate using Entity Framework

    Hi,i have table in SQL Server named Employees as follows:
    EmployeeId lastName FirstName reportsTo
    1 Davolio Nancy 2
    2 Fuller Andrew NULL
    3 Leverling Janet 2
    4 Peacock Margaret 2
    5 Buchanan Steven 2
    6 Suyama Michael 5
    7 King Robert 5
    8 Callahan Laura 2
    9 Dodsworth Anne 5
    I would like to use Entity Framework to populate my Model Class .My model class looks as follows:
    public class Employees
        readonly List<Employees> _children = new List<Employees>();
        public IList<Employees> Children
            get { return _children; }
        public string FirstName { get; set; }
        public string LastName {get; set;}
    I want to use this class in ViewModel  to populate my TreeView control. Can anyone help me in order to define Linq to Entities in order to populate my model class Employees from table in SQL Server as defined. Thanks in advance.
    Almir

    Hello Fred,
    unfortunately it does not work, maybe I can be more specific about what I'm trying to get. I'm following Josh Smith's article on CodeProject related to WFP TreeView
    Josh Smith article. He has Class named Person with the following structure
    public class Person
    readonly List<Person> _children = new List<Person>();
    public List<Person> Children
    get
    return _children;
    public string Name { get; set; }
    The same is populated from Database class using method named GetFamilyTree() which look as follows:
    public static Person GetFamilyTree()
    // In a real app this method would access a database.
    return new Person
    Name = "David Weatherbeam",
    Children =
    new Person
    Name="Alberto Weatherbeam",
    Children=
    new Person
    Name="Zena Hairmonger",
    Children=
    new Person
    Name="Sarah Applifunk",
    new Person
    Name="Jenny van Machoqueen",
    Children=
    new Person
    Name="Nick van Machoqueen",
    new Person
    Name="Matilda Porcupinicus",
    new Person
    Name="Bronco van Machoqueen",
    new Person
    Name="Komrade Winkleford",
    Children=
    new Person
    Name="Maurice Winkleford",
    Children=
    new Person
    Name="Divinity W. Llamafoot",
    new Person
    Name="Komrade Winkleford, Jr.",
    Children=
    new Person
    Name="Saratoga Z. Crankentoe",
    new Person
    Name="Excaliber Winkleford",
    I'm trying to figure out how should I write
    GetFamilyTree() method using Entity Framework in order to connect to my SQL Server database and populate this Person class as it was populated manually in Joshs Example. The table I'm using in SQL Server is described in
    my first post named Employees (it's self reference table)

  • Custom mapping is obviously not reflected in the Entity Framework designer

    Hi,
    I use the Oracle Data Provider for .NET 11.2.0.2.50 Beta 3 with the Entity Framework. I added a custom mapping to the app.config that maps NUMBER(1,0) to bool:
    <oracle.dataaccess.client>
    <settings>
    <add name="bool" value="edmmapping number(1,0)" />
    </settings>
    </oracle.dataaccess.client>
    When I create an Entity Framework model from my Oracle database the EF designer uses Int16 for NUMBER(1,0) fields instead of bool. If I run the program I then get an exception (as expected):
    "Schema specified is not valid. Errors:
    EntityFrameworkTest.msl(7,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.Int16[Nullable=True,DefaultValue=]' of member 'ISVIPCUSTOMER' in type 'EntityFrameworkTestModel.CUSTOMER' is not compatible with 'OracleEFProvider.number[Nullable=True,DefaultValue=,Precision=1,Scale=0]' of member 'ISVIPCUSTOMER' in type 'EntityFrameworkTestModel.Store.CUSTOMERS'."
    Okay. Assuming it's an error in the EF designer, I set the type Boolean in the model myself for the NUMBER(1,0) fields. But that gives me a compilation error:
    "Error 2019: Member Mapping specified is not valid. The type 'Edm.Boolean[Nullable=True,DefaultValue=]' of member 'ISVIPCUSTOMER' in type 'EntityFrameworkTestModel.CUSTOMER' is not compatible with 'OracleEFProvider.number[Nullable=True,DefaultValue=,Precision=1,Scale=0]' of member 'ISVIPCUSTOMER' in type 'EntityFrameworkTestModel.Store.CUSTOMERS'."
    Is this a bug in the provider? Or am I missing something?

    Are you using model first or database first? If you're using database first, make sure you update the model from the database after adding that configuration.
    Also, if your model is in a different assembly (ie a different project) from your executable, your executable project's configuration file also needs the mapping section.
    Finally... there's been a LOT of threads about this not working properly in beta 3. I'm still on beta 2 and except for some incorrect error messages in the designer it works fine (I get fake errors). If nothing else works, I might suggest trying beta 2 as a last resort.

  • Entity framework-calling stored Proc to return one param returns ORA-6550

    Hi There,
    I am new to the VS2010/MVC3 game with ODP.net, so no abuse please .......
    I have successfully inserted a record into a table via the controller/entity framework, but only by currently hard coding the id. The next logical step is to attempt to obtain the id from the Oracle DB via a stored procedure. Here is the body of the PL/SQL procedure on the Oracle side:-
    create or replace package body dotnetcommon as
    PROCEDURE getnextpoid ( p_to_id OUT NUMBER ) IS
    BEGIN
         SELECT pord_seq.nextval INTO p_to_id FROM dual;
    END getnextpoid;
    end dotnetcommon;
    show error
    I have then added this procedure to my Entity Framework Model within VS2010 , and from within the Model Browser, I now have a stored procedure of "DOTNETCOMMON_GETNEXTPOID" under my Model.Store. This has an out type parameter named p_to_id, which is a type of number.
    I then added a function import, so I have a function by the name of "GETNEXTPOID" under the Function Imports folder, with a collection property of 'None'.
    This function has a parameter P_TO_ID with a type of "Decimal".
    From within my controller, I have the following code:-
    [HttpPost]
    public string Create(PURCHASEORDER po)
    TasEntities tmprep = new TasEntities();
    ObjectParameter poid = new ObjectParameter("poId", typeof(Int16));
    var result = tmprep.GETNEXTPOID(poid);
    return "Next PO Id is " + result;
    Thus, on pressing the Save from my view, i am hoping to return the next logical sequence number into the poid objectparameter. However, I am presented with the following error:-
    Inner Exception of:-
    {"ORA-06550: line 1, column 8:\nPLS-00306: wrong number or types of arguments in call to 'GETNEXTPOID'\nORA-06550: line 1, column 8:\nPL/SQL: Statement ignored"}
    It falls over , taking me to the Model.Designer.cs at :-
    public int GETNEXTPOID(ObjectParameter p_TO_ID)
    return base.ExecuteFunction("GETNEXTPOID", p_TO_ID);
    I am assuming it is to do with the decimal/int/number conversion, but I do not have the nouse to fix it ? Does anybody know what is wrong with what I have attempted to do above ?
    Please please get back to me if you need any more information, I am wanting to move on but cannot.
    I have seen posts regarding setting the sequence in a before insert trigger on the table, but this is not ideal. Can the above not work instead ?
    Many thanks in advance for any help you can provide.
    Graeme
    Edited by: user4487499 on 05-Apr-2011 08:18

    I have now raised this in the odp.net forum, as on looking at other posts it seems to be the best place for it.
    Cheers,
    Graeme
    Edited by: user4487499 on 05-Apr-2011 08:18
    Edited by: user4487499 on 05-Apr-2011 13:00

  • Get entity as return of collection in entity framework

    how to get entity as return of collection in entity framework,,, i dont have any idea...
    when i select entity and then get column information then no column return .....

    The way the Oracle provider works right now requires that you use a cursor, even if you want to map it to an entity. To map it to an entity, that cursor needs to contain the necessary columns to form the entity (ie: it's returning data from the same table).
    Here's an example from one I have mapped:
    CREATE OR REPLACE PROCEDURE ENVMSTR.P_ORG_UNIT_R_BY_STAFF
    STAFF_ID_P IN NUMBER
    , RESULT_CURSOR_P OUT SYS_REFCURSOR
    ) AS
    BEGIN
    OPEN RESULT_CURSOR_P FOR
    select *
    from dept_organizational_unit d
    where deptorgunit_cd = (select deptorgunit_cd from staff where staff_id = STAFF_ID_P)
    or deptorgunit_cd in ( select deptorgunitrel_parent_cd from dept_org_unit_relation
    start with deptorgunitrel_child_cd = (select deptorgunit_cd from staff where staff_id = STAFF_ID_P)
    connect by prior deptorgunitrel_parent_cd = deptorgunitrel_child_cd);
    END P_ORG_UNIT_R_BY_STAFF;
    web.config:
    <add name="ENVMSTR.P_ORG_UNIT_R_BY_STAFF.RefCursor.RESULT_CURSOR_P" value="implicitRefCursor bindinfo='mode=Output'" />
    With those things set up, I'm able to import the function and map it to the entity that represents the dept_organizational_unit table (that entity is called OrgUnit in the model, but it doesn't really matter what you call it). The interesting thing I found is that in this situation I didn't actually have to add config file entries for each column in the cursor, probably because it maps perfectly to the entity. If I was trying to use a complex type instead then I probably would (and the configuration required to do that gets horrific in a hurry).

  • Multiple database users, ORM, entity framework, best practices

    Hello everyone!
    You've already helped me several times, however I must ask for an advice once more.
    I was assigned to develop .NET application with Data Access Layer and I've decided to use Oracle Database Software to provide sample data.
    As I'm absolute novice considering creating DAL I'd be grateful if you can examine my plan in terms of security and reliability:
    My database:
    1) I've created database with sample tables and relations between them. All tables belongs to databaseAdmin.
    2) I've created HR and Manager database users and granted them some privileges on certain databaseAdmin's tables. My intention is to reduce access to unnecessary tables. If my application user want to make some changes to Customers table it should be enough to connect to database as HR.
    And now I'd like to map my database using Entity Framework in my application. And that's where I have a problem:
    -If I create Entity Model basing on databaseAdmin tables I get perfect model, however every Entity SQL query would be executed on behalf of databaseAdmin, which breaks my idea of hiding unnecessary tables.
    -If I create Entity Model for HR and Manager users, my models could overlap on tables that both users have access to and no connection between tables would be generated (as from their point of view those tables are just some tables that belong to databaseAdmin)
    Could you help me with this deadlock? Or maybe my assumptions about multiple database users are incorrect? Please, bear in mind I'm a novice.
    I was trying to find a solution in web, and there're tons of data discussing technical aspects of Entity Framework etc., but not so many documents about conceptual model of database.

    hi Michael,
    Thanks for you posting!
    Sorry for I am not totally understanding your issue. Maybe two points need your confirm:
    1. I confuse with the "Service controller"? IS your meaning MVC controller? Or ServiceController(http://www.codeproject.com/Articles/31688/Using-the-ServiceController-in-C-to-stop-and-start
    2.whether  The type of ID in the model is match to the database ? In other words, Is the type of IDin .edmx matched to the database?
    By the way, it seems that this issue is more related to EF. You could post this issue on EF discussion for better support.
    Thanks & Regards,
    Will
    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.

  • Entity framework TPT does not work - showstopper

    Greetings,
    I'm experiencing a similar problem that is described here:
    [Entity Framework and inheritance - Possible bug in EF?|http://stackoverflow.com/questions/11506683/entity-framework-and-inheritance-possible-bug-in-ef.]
    I'm using:
    Windows 7 64 bit
    ODAC 11.2 Release 5 32 bit
    Oracle Express 11.2 on localhost
    Visual Studio 2012
    Entity framework 5.0
    .net 4.5
    Create a simple database with TPT inheritance:
    CREATE TABLE Person(
    Id NUMBER(38, 0) NOT NULL,
    Name VARCHAR2(50),
    CONSTRAINT PK100 PRIMARY KEY (Id)
    CREATE TABLE Employee(
    Id NUMBER(38, 0) NOT NULL,
    JobTitle VARCHAR2(50),
    CONSTRAINT PK101 PRIMARY KEY (Id)
    ALTER TABLE Employee ADD CONSTRAINT ref_Employee_person
    FOREIGN KEY (Id)
    REFERENCES Person(Id)
    CREATE TABLE Superhero(
    Id NUMBER(38, 0) NOT NULL,
    Superpower VARCHAR2(50),
    CONSTRAINT PK102 PRIMARY KEY (Id)
    ALTER TABLE Superhero ADD CONSTRAINT ref_Superhero_person
    FOREIGN KEY (Id)
    REFERENCES Person(Id)
    -- Sequence
    CREATE SEQUENCE seq_id
    INCREMENT BY 1
    START WITH 55
    MINVALUE 1
    MAXVALUE 9999999999999999999999999999
    NOCYCLE
    NOORDER
    CACHE 20
    CREATE OR REPLACE TRIGGER PERSON_BI BEFORE INSERT ON PERSON FOR EACH ROW
    BEGIN IF :NEW.ID IS NULL THEN SELECT SEQ_ID.NEXTVAL INTO :NEW.ID FROM DUAL; END IF; END;
    Create a console application, add an edmx file, set up inheritance like so:
    Diagram
    And I set the Id property in Person entity as StoreGeneratedPattern to Identity
    Then I created the following program:
    static void Main(string[] args)
    //Employee
    var db = new Entities();
    EMPLOYEE e = new EMPLOYEE() { ID = 0, JOBTITLE = "Programmer"};
    e.NAME = "John Regular Doe";
    db.People.Add(e);
    //Superhero
    SUPERHERO s = new SUPERHERO();
    s.NAME = "Superman";
    s.SUPERPOWER = "Flight";
    db.People.Add(s);
    db.SaveChanges();
    //Fetch all persons and look at the type
    //this is where I get an error:
    var allPeople = db.People.ToList();
    allPeople.ForEach(x => Console.WriteLine("type: " + x.GetType()));
    This throws the following error when I fetch into allPeople:
    All objects in the EntitySet 'Entities.People' must have unique primary keys. However, an instance of type 'TestingTPTInheritance.EMPLOYEE' and an instance of type 'TestingTPTInheritance.SUPERHERO' both have the same primary key value, 'EntitySet=People;ID=38'.
    Looking at the database everything looks fine
    -- Person table --
    ID     NAME
    39     John Regular Doe
    40     Superman
    -- Employee table --
    ID     JOBTITLE
    39     Programmer
    -- Superhero table --
    ID     SUPERPOWER
    40     Flight
    If I take the select that EF generates in " db.People.ToList();" and run it I get the following result:
    C1      C2     NAME      C3      C4
    0X0X     40     Superman           
    0X0X     39     John Regular Doe     Programmer     
    Is this a bug in ODAC. If so is there a workaround or will there be a fix soon?
    Edited by: Amplus on 7.11.2012 07:59

    Thank you for the reply shsu
    I was being careless when I copied the error message and sequence, sorry about that. I did run this serveral times after I copied the error message. I recreate the seqence starting with 1 and recreated the problem. The error message is:
    All objects in the EntitySet 'Entities.People' must have unique primary keys. However, an instance of type 'TestingTPTInheritance.EMPLOYEE' and an instance of type 'TestingTPTInheritance.SUPERHERO' both have the same primary key value, 'EntitySet=People;ID=2'.
    The data in the tables is:
    Person:
    ID     NAME
    1      John Regular Doe
    2      Superman
    employee
    ID     JOBTITLE
    1      Programmer
    Superhero
    ID     SUPERPOWER
    2      Flight
    And the generated select is:
    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"."ID" AS number(19,0)) AS "C2",
    "Extent1"."NAME" AS "NAME",
    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"."JOBTITLE" END AS "C3",
    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 NULL ELSE "Project2"."SUPERPOWER" END AS "C4"
    FROM "TPT"."PERSON" "Extent1"
    LEFT OUTER JOIN (SELECT
    "Extent2"."JOBTITLE" AS "JOBTITLE",
    CAST( "Extent2"."ID" AS number(19,0)) AS "C1",
    1 AS "C2"
    FROM "TPT"."EMPLOYEE" "Extent2" ) "Project1" ON ( CAST( "Extent1"."ID" AS number(19,0))) = "Project1"."C1"
    LEFT OUTER JOIN (SELECT
    "Extent3"."SUPERPOWER" AS "SUPERPOWER",
    CAST( "Extent3"."ID" AS number(19,0)) AS "C1",
    1 AS "C2"
    FROM "TPT"."SUPERHERO" "Extent3" ) "Project2" ON ( CAST( "Extent1"."ID" AS number(19,0))) = "Project2"."C1"
    With the following result:
    C1      C2     NAME      C3      C4
    0X0X     2      Superman      null      null --> should't there be a "Flight" entry here??
    0X0X     1      John Regular Doe     Programmer     null
    I also tried this:
    var result1 = db.People.OfType<SUPERHERO>().ToList(); //Count=1
    var result2 = db.People.OfType<EMPLOYEE>().ToList(); //Count=1
    var result3 = db.People.OfType<PERSON>().ToList(); //Throws the following error:
    All objects in the EntitySet 'Entities.People' must have unique primary keys. However, an instance of type 'TestingTPTInheritance.EMPLOYEE' and an instance of type 'TestingTPTInheritance.SUPERHERO' both have the same primary key value, 'EntitySet=People;ID=2'.
    The only thing I can think of is that my little console app is picking up the oracle client from oracle express instead of the ODAC driver. Is there an easy way to force it to use the correct driver? I have this in my config file but I'm not sure if it works:
    <oracle.dataaccess.client>
    <settings>
    <add name="DllPath" value="C:\oracle\product\11.2.0\client_3\bin" />
    </settings>
    </oracle.dataaccess.client>
    And I have also referenced Oracle.Data.Access here:
    C:\oracle\product\11.2.0\client_3\odp.net\bin\4\Oracle.DataAccess.dll
    client_3 directory is my ODAC Release 5 installation. I changed the config settings to:
    <oracle.dataaccess.client>
    <settings>
    <add name="DllPath" value="C:\oracle\product\11.2.0\client_3\odp.net\bin\4\Oracle.DataAccess.dll" />
    </settings>
    </oracle.dataaccess.client>
    then the program was able to run this line:
    var allPeople = db.People.ToList();
    But both objects were of type EMPLOYEE. Then I ran this:
    var result1 = db.People.OfType<SUPERHERO>().ToList();
    and get the following error:
    All objects in the EntitySet 'Entities.People' must have unique primary keys. However, an instance of type 'TestingTPTInheritance.EMPLOYEE' and an instance of type 'TestingTPTInheritance.SUPERHERO' both have the same primary key value, 'EntitySet=People;ID=2'.
    The problem must be that I do have multiple versions of Oracle client installed on my computer and it is picking up the wrong one either when I'm generating the edmx file or when the application is connecting to the db. I think my next step will be to uninstall all oracle client instances as well as oracle express and try again from scratch!!

  • 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

  • WCF Data Service from Entity Framework 5 in SharePoint 2013

    not sure which forum is best, so im going to throw it in here.
    I am working on a proof of concept. I want to create a WCF Data Service within sharepoint 2013. not only do i want to do that, i want to use the Entity Framework 5 to expose the data via OData. Now, I have crawled the internet and seen various examples of
    how to create wcf data services and wcf services in sharepoint 2010/2013. and have tried to apply those as needed to create this POC. So.. what I have done so far. 
    MonitoringData.cs
    [BasicHttpBindingServiceMetadataExchangeEndpoint]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    [System.Runtime.InteropServices.Guid("0185abf6-e8b8-42e2-9965-6bb644338077")]
    public class MonitoringData : DataService<MonitoringServiceEntities>
    // This method is called only once to initialize service-wide policies.
    public static void InitializeService(DataServiceConfiguration config)
    // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
    // Examples:
    config.SetEntitySetAccessRule("*", EntitySetRights.AllWrite);
    config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
    config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
    MonitoringData.svc:
    <%@ServiceHost Language="C#" Debug="true"
    Service="$SharePoint.Type.0185abf6-e8b8-42e2-9965-6bb644338077.AssemblyQualifiedName$"
    Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressDataServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    upon deployment, this error when hitting the https://server/_vti_bin/poc/monitoringdata.svc/$metadata
    "The type 'xxxxxxxx', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could
    not be found."
    Breaking out the google-fu, i found that adding the dll to the <compilation> section was needed for the web.config. so i did that. and now i just get a blank screen with no errors.
    so i crack open fiddler. i see the following 
    200 http
    tunnel to
    server:443 0
    401 https
    server /_vti_bin/poc/monitoringdata.svc/$metadata
    16
    401
    https server
    /_vti_bin/poc/monitoringdata.svc/$metadata
    0
    404
    https server
    /_vti_bin/poc/monitoringdata.svc/$metadata
    0
    best i can see is that im either not authorized, and its returning null (which shouldnt be the case) or something is just busted.
    The goal is to use ntml auth and https to connect to this service. any ideas?

    One thing I found was that it's never worth the trouble to place the WCF service in a web site running SharePoint, it's better to place it in a dedicated web site, as described in this article:
    http://sharepointdragons.com/2011/10/07/parallel-programming-in-sharepoint-2010-the-back-to-the-future-pattern/
    It's usually too much work to get the web.config settings right because of the settings it inherits from its parents.
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com
    I'll say that it is one solution to move the WCF Service outside of sharepoint. but my "1000 mile" requirements makes this a necessity. 
    To broaden the scope of what I am doing, I have a custom SharePoint Service Application. this custom application has a proxy that used a restful interface. Now, with all the methods i will have to write (over 100, x3 for all of the "proxy to a proxy" scenarios)
    I wanted to explore the idea of using odata. so i can use the various clients to write their own queries instead of me writing them all and exposing them. especially since its all linq queries to a database underneath. I feel that I am missing some specific
    component to make this work, and its surely due to my incomplete knowledge of WCF or EF.

  • Best Practices for Using Service Controller for Entity Framework Database

    I'm running into an issue in my first time creating a Web Service with a .NET backend with Azure. I designed a database in Entity Framework and had it create the models, but I couldn't create a controller for the table unless I made the model inherit from
    EntityData. Here's the catch, the Database Model has int Id, but EntityData has string Id, so, of course, I'm getting errors. What is best practice for what I'm trying to do?
    Michael DiLeo

    hi Michael,
    Thanks for you posting!
    Sorry for I am not totally understanding your issue. Maybe two points need your confirm:
    1. I confuse with the "Service controller"? IS your meaning MVC controller? Or ServiceController(http://www.codeproject.com/Articles/31688/Using-the-ServiceController-in-C-to-stop-and-start
    2.whether  The type of ID in the model is match to the database ? In other words, Is the type of IDin .edmx matched to the database?
    By the way, it seems that this issue is more related to EF. You could post this issue on EF discussion for better support.
    Thanks & Regards,
    Will
    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.

  • Seeding multiple databases with single Entity Framework context

    I am developing a single-instance, multi-tenant web application, with a SQL database using Entity Framework 6 Code-First. 
    I want to have a separate database for each client, generated from the same EF models, with a single DbContext. The database to connect to will be determined by the subdomain that the client is using the web app from. 
    This seems to work fine and the correct database is connected to depending on the subdomain. However my issue is seeding the databases with data. This is the code I have:
    foreach (var connString in ConfigurationManager.ConnectionStrings.Cast<ConnectionStringSettings>()))
    Configuration.PerformDatabaseMigration(connString.Name);
    This then calls the PerformDatabaseMigration method: 
    public class Configuration : DbMigrationsConfiguration<DataContext>
    public Configuration()
    AutomaticMigrationsEnabled = false;
    AutomaticMigrationDataLossAllowed = false;
    public static void PerformDatabaseMigration(string connStringName)
    var databaseInitialiser = new Configuration { TargetDatabase = new DbConnectionInfo(connStringName) };
    var dbMigrator = new DbMigrator(databaseInitialiser);
    dbMigrator.Update();
    protected override void Seed(DataContext context)
    base.Seed(context);
    var superAdmin = new User { Id = 1, UserName = "SuperAdmin" };
    context.Users.AddOrUpdate(superAdmin);
    The issue is that when seeding this data for the second database, the context passed into the Seed method already has the admin user added to the `DbSet<User>` property of the context, even though the context is for the second databse connection, not
    the first. It appears that the context is not being cleared from seeding the first database, and so I receive a `DbUpdateException`, as my User.Username field is a unique index.
    Cannot insert duplicate key row in object 'dbo.Users' with unique index 'IX_UserName'. The duplicate key value is (SuperAdmin).\r\nThe statement has been terminated.
    public class User : ModelBase, IUserIdentity, IPrincipal, IIdentity 
        [Index(IsUnique = true)]     
      [Required]     
      [StringLength(40)]       
    public string UserName { get; set; }

    Hello Attune,
    >>This seems to work fine and the correct database is connected to depending on the subdomain. However my issue is seeding the databases with data.
    Is that you firstly create these databases and then call the PerformDatabaseMigration method to seed these database with data? Do you have a try to seed these database data when creating the database with AutomaticMigrationsEnabled = true; with your provided
    configuration class, I tested it and it could work as seeding same data to different database:
    internal sealed class Configuration : DbMigrationsConfiguration<CFs.CFContext>
    public Configuration()
    AutomaticMigrationsEnabled = true;
    public static void PerformDatabaseMigration(string connStringName)
    var databaseInitialiser = new Configuration { TargetDatabase = new DbConnectionInfo(connStringName) };
    var dbMigrator = new DbMigrator(databaseInitialiser);
    dbMigrator.Update();
    protected override void Seed(CFs.CFContext context)
    base.Seed(context);
    var superAdmin = new ApplicationUser() { ApplicationUserID = 1, FirstName = "", LastName = "" };
    context.ApplicationUsers.AddOrUpdate(superAdmin);
    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.

  • 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.

Maybe you are looking for

  • HT4759 icloud is not supported on windows, but exe files can still be installed

    why is icloud so damm hard to use on windows ?  i have no apple devices, wont like one if thats will be so hard everytime to make a simple thing with apple

  • List of Network Users in Loginwindow Omitted

    I have a Mountain Lion 10.8.5 client machine joined to a Mountain Lion 10.8.5 OS X Server on which I have completed DNS, OD, and network account configuration steps.  I have added a network account on the server (and Server.app displays the account a

  • ICal suddenly changed to December 2000 and can't change it?

    Hi All, This morning my computer froze and I had to restart it. When I turned it back on my iCal seems to think it is December of 2000 and I can't seem to fix it. Does anyone know a fix for this? It's really messing me up! Thanks in advance, Stephani

  • Problem with Mutt

    I'm using Mutt with a Gmail account via IMAP, and keep getting warnings Mailbox was externally modified. Flags may be wrong. every time when I move with "s" command a message to +[Gmail]/Trash. Not sure on which side (Mutt or Google) this bug is, but

  • Help on keyboard codes

    wat is the code for shift