Declaring Navigation Property in Entity Framework

Hi,
I developed a sample application in EF which has 3 tables 
PersonDetails, BankDetails and FixedDepositDetails. Please find the table structure below
create table PersonDetails
(PersonId int Primary Key,
PersonName varchar(30))
create table BankDetails
(BankId int Primary Key,
BankName varchar(100),
BankBranch varchar(100),
BankLocation varchar(100))
create table FixedDepositDetails
Id int Primary Key,
FixedDepositNo varchar(30) not null,
Bank_Id int, -- references Bank Details
Person_Id int, -- references Person Details
DOD datetime,
DOM datetime,
DepositAmount decimal(9,2),
MaturityAmount decimal(9,2),
ROI decimal(3,2),
Period varchar(20),
Parent_Id int,
Constraint fk_BankId Foreign Key(Bank_Id) references BankDetails(BankId),
Constraint fk_PersonId Foreign Key(Person_Id) references PersonDetails(PersonId),
Constraint fk_ParentId Foreign Key(Parent_Id) references FixedDepositDetails(Id)
Now in the Entity framework I have specified as given below
[Serializable]
public class PersonDetails
[Key]
public int PersonId { get; set; }
public String PersonName { get; set; }
[Serializable]
public class BankDetails
[Key]
public int BankId { get; set; }
public String BankName { get; set; }
public String BankBranch { get; set; }
public String BankLocation { get; set; }
[Serializable]
public class FixedDepositDetails
[Key]
public int Id { get; set; }
public String FixedDepositNo { get; set; }
[ForeignKey("Bank_Id")]
public int? Bank_Id { get; set; }
public BankDetails BankDetails { get; set; }
[ForeignKey("Person_Id")]
public int? Person_Id { get; set; }
public PersonDetails PersonDetails { get; set; }
public DateTime DOD { get; set; }
public DateTime DOM { get; set; }
public decimal DepositAmount { get; set; }
public decimal MaturityAmount { get; set; }
public decimal ROI { get; set; }
public String Period { get; set; }
[ForeignKey("Parent_Id")]
public int? Parent_Id { get; set; }
public FixedDepositDetails FixedDepositDetail { get; set; }
} public class BaseDBContext : DbContext
        public BaseDBContext(string ConnectionString)
            : base(ConnectionString)
        public DbSet<PersonDetails> PersonDetails { get; set; }
        public DbSet<BankDetails> BankDetails { get; set; }
        public DbSet<FixedDepositDetails> FixedDepositDetails { get; set; }
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
            modelBuilder.Entity<FixedDepositDetails>()
                .HasRequired(x => x.BankDetails)
                .WithMany()
                .HasForeignKey(y => y.Bank_Id);
            modelBuilder.Entity<FixedDepositDetails>()
               .HasRequired(x => x.PersonDetails)
               .WithMany()
               .HasForeignKey(y => y.Person_Id);
But when I run the application I get an error as
The navigation property 'Bank_Id' is not a declared property on type 'FixedDepositDetails'. Verify that it has not been explicitly excluded from the model and that it is a valid navigation property.
If I am not wrong I think I have made some mistakes when creating the model. Can some some please let me know where I am doing the mistake? If some one is able to provide me with a solution Please explain me as what you are doing and why that solution needs
to be done?
Regards,
Raghul

I know this is an old thread, but when doing it either way you guys described, I get:
"The foreign key component 'FixedDepositDetail' is not a valid navigation property on type 'PersonDetails'.
Verify that it has not been explicitly excluded from the model and that it is a valid primitive property."
I had my own one-to-many relationship, but for the sake of not involving new items, it mirrors this setup from above:
public class PersonDetails
{ [Key]
public int PersonId { get; set; }
public String PersonName { get; set; } public virtual ICollection<FixedDepositDetails> FixedDepositDetail { get; set; }
} public class FixedDepositDetails
[Key]
public int Id { get; set; } public int? Person_Id { get; set; } [ForeignKey("Person_Id")]
public PersonDetails PersonDetails { get; set; } public FixedDepositDetails FixedDepositDetail { get; set; }
Any ideas on how this setup should work, or is this what you guys have?

Similar Messages

  • Creating (POST) an entity via a navigation property?

    Hi All,
    Let's say we have a model that has an Employees entityset, and for a given employee, you can navigate to a CurrentCarParkingSpot entity (it's an example not reality).
    e.g. Employees('00123456')/CurrentCarParkingSpot would pull up the current CarParkingSpot against the Employee.
    Now if the employee didn't have a CarParkingSpot, and I want to create a new CarParkingSpot for this employee, you would think I could POST a standard CarParkingSpot payload to Employees('00123456')/CurrentCarParkingSpot and it should create a new CarParkingSpot against employee (assuming I get the employee key in the GW code). However, when I try this, the framework doesn't even call my code, and it's almost like Gateway does not support creation via a navigation property. PUT works, just not POST.
    Note - If I post the same payload directly to /CarParkingSpots, it works fine.
    e.g. The payload looks like:
    <?xml version="1.0" encoding="utf-8"?>
    <entry xml:base="http://server.local/sap/opu/odata/sap/ZEXAMPLE/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
      <id>http://server.local/sap/opu/odata/sap/ZEXAMPLE/CarParkingSpot</id>
      <title type="text">CarParkingSpot</title>
      <category term="ZEXAMPLE.CarParkingSpot" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
      <content type="application/xml">
       <m:properties>
       </m:properties>
      </content>
    </entry>
    So the key question: Is creation (POST) via Navigation Properties supported in GW, and if it is, do you need to alter the payload at all (note - I've tried changing the id and text above to align with navigation property)?
    FYI - I've been testing via Gateway Client, and getting successful creation by using "Use as request" from an existing specific Employees('another id')/CurrentCarParkingSpot and removing all id's in the POST payload.
    Thanks,
    Matt

    Hi Matt,
    This is a limitation of GW, not OData. If you peruse some non-SAP OData resources you will find mention of posting to navigations.
    The OData 4.0 spec states:
    To create an entity in a collection, the client sends a POST request to that collection's URL. The POST body MUST contain a single valid entity representation.
    An entity may also be created as the result of an Upsert operation.
    If the target URL for the collection is a navigation link, the new entity is automatically linked to the entity containing the navigation link.
    The GW framework requires you to POST to a canonical URI, i.e. unnavigated direct address.
    In my view navigated POST should be supported by GW otherwise it imposes unrealistic design issues, e.g. you now have to include the key of a parent into a child entity to satisfy your requirement.
    There are other reasons why it's desirable to POST to the navigation endpoint.
    1 - As the navigation points get longer, the need to add more key properties to the endpoint arises:
    e.g. for myservice/entityset1(1)/entityset2(2)/siblings(3)/classifications, the classifications entity needs three properties that probably aren't anything like the canonical URI.
    This will, at code level mean there are going to be divergences in the access methods that don't need to be present.
    2 - The canonical URI may not be addressable. In the above example, classifications is not likely to be something that has any context outside of a navigated path,so a canonical URI for posting one cannot be established.
    I don't know why SAP haven't allowed this as the runtime components certainly have the potential to expose the navigation context if the POST request was allowed in.
    In the interim, it might be possible design a model that would allow pseudo-navigation posting by using a batched request, so I may have a look into this.
    Regards
    Ron.

  • Good practice for async databinding, regarding entity-framework.

    I have some issue to find a good pattern to keep my UI responsive using asynch databinding and entity framework which is not thread-safe. It would be a shame if the UI came to totaly freeze with no feedback for a connection lost.
    So, entity framework is not thread-safe. Which mean I won't be able to rely on lazy loading here and involve than if I do async databinding to a collection of object, each object will have to load their navigations properties with their own context to display
    data. Ok, I can handle this. But what if I need more than displaying data and I want to modify a navigation property ?
    I need when I set the navigation property in my viewmodel to attach an entity from the same context than the parent entity is from. So here I have one context for multiple thread. What do I do ? =(
    Does anyone have some experience in it and can help me to clear this mess from my mind ? =D
    All the sample I can find about async databinding don't go any further than make a Thread.Sleep before returning a string, it's not realy helpfull.

    There are reasons people post simple explanations.
    One of those is because they post blog entries when they're learning something rather than when they are expert in it.  The blog post is part of their learning process.
    I sometimes share context. 
    What I do is put the context in Application.Current.Resources and then go get it from there when I need to re-use that particular one.
    xxxDomainContext DBContext = new xxxDomainContext();
    Application.Current.Resources.Add("DBContext", DBContext);
    and using that:
    context = (xxxxDomainContext)Application.Current.Resources["DBContext"];
    You can alternatively share collections in a similar way.  Depends on how many related tables you have, but reading a whole tree of static data is sometimes a good idea rather than just one table at a time.
    One technique I use is to cache slowly changing data on the client and then go get changes since the last run off the server.  For a fair few applications, yesterdays data is good enough for most data sets.  It's just the odd one or two which you really
    need up to date numbers or whatever.
    You can see a collection shared in this sample ( but the sharing is for different reasons ) :
     https://gallery.technet.microsoft.com/Dynamic-XAML-Composed-View-e087f3c1
    Please don't forget to upvote posts which you like and mark those which answer your question.
    My latest Technet article - Dynamic XAML

  • Missing declared association property

    A fill command like so:
    <mx:Button label="Fill" click="{se.fill(entitymaps)}"/>
    In this data service:
    <mx:DataService id="se" destination="entityds"/>
    Gives the following stack trace:
    Error: Item added to destination: entityds of type: maps::EntityMap is missing declared association property: children
        at mx.data::ConcreteDataService/http://www.adobe.com/2006/flex/mx/internal::checkAssociations()[C:\depot\DataServices\bran ches\lcds26_hotfixes\frameworks\projects\data\src\mx\data\ConcreteDataService.as:2154]
        at mx.data::DataList/http://www.adobe.com/2006/flex/mx/internal::processSequence()[C:\depot\DataServices\branch es\lcds26_hotfixes\frameworks\projects\data\src\mx\data\DataList.as:2060]
        at mx.data::DataList/http://www.adobe.com/2006/flex/mx/internal::processSequenceResult()[C:\depot\DataServices\ branches\lcds26_hotfixes\frameworks\projects\data\src\mx\data\DataList.as:2284]
        at DataListRequestResponder/result()[C:\depot\DataServices\branches\lcds26_hotfixes\framewor ks\projects\data\src\mx\data\ConcreteDataService.as:7283]
        at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\ AsyncRequest.as:74]
        at NetConnectionMessageResponder/resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\ src\mx\messaging\channels\NetConnectionChannel.as:515]
        at mx.messaging::MessageResponder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx \messaging\MessageResponder.as:199]
    When the 'children' property of EntityMap is not declared, EntityMap looks like this:
    package maps
        import mx.collections.ArrayCollection;
        [Managed]
        [RemoteClass(alias="alex.onetomany.Entity")]
        public class {   
            public function EntityMap() {}      
            public var name:String;
            public var identity:String;
    Despite the fact that the entityds destination looks like this......
    <destination id="entityds">
            <properties>
                <source>alex.onetomany.EntityAssembler</source>
                <scope>application</scope>
                <metadata>
                    <identity property="identity"/>
                </metadata>
                <network>
                    <paging enabled="false" pageSize="10" />
                </network>
            </properties>
        </destination>
    ...the problem still seems to occour. The strangest thing is when I rename the destination from entityds to 'blah' (on the server in data-management-config.xml and on the client in my MXML file OneToManyTest.mxml) the error no longer happens.
    Questions:
    1) When exactly is the missing declared association property: supposed to appear? Is it when you add some associated property in data-management-config.xml, if so....
    2) How come it does not appear for the nodeds data service when I give it a similar children property on-to-many configuration in data-management-service.xml like so:
        <destination id="nodeds">
            <properties>
                <source>alex.onetomany.NodeAssembler</source>
                <scope>application</scope>
                <metadata>
                    <identity property="identity"/>
                    <one-to-many property="children" destination="nodeds"
                        load-on-demand="true"
                        read-only="true"
                        lazy="false"/>
                </metadata>
                <network>
                    <paging enabled="false" pageSize="1" />
                </network>
            </properties>
        </destination>
    3) Most importantly: why does it appear for entityds and only when the destination is called entityds and nothing else.

    Do you have the XML request that you are sending?

  • Entity Framework doesn't save new record into database

    Hy,
    I have problem with saving new record into database using Entity Framework.
    When I run program, everything seems normal, without errors . Program shows existing, manually added records into the database, and new one too. But new one isn't save into database after running program.
    I've got no idea where's problem. There is code for add new record, show existing.
    Thanks for help!!
    // add new record
    using (var db=new DatabaseEntitiesContext())
    var person = new Table()
    First_Name = "New_FName",
    Second_Name = "New_SName",
    PIN = "4569"
    db.Tables.Add(person);
    db.SaveChanges();
    //show all records
    using (var db=new DatabaseEntitiesContext())
    var selected = from x in db.Tables
    select x;
    foreach (var table in selected)
    Console.WriteLine("{0}{1}{2}",table.First_Name,table.Second_Name,table.PIN);

    Hi BownieCross;
    If you are using a local database file in your project the following may be the cause.
    From Microsoft Documentation:
    Issue:
    "Every time I test my application and modify data, my changes are gone the next time I run my application."
    Explanation:
    The value of the Copy
    to Output Directory property is Copy
    if newer or Copy
    always. The database in your output folder (the database that’s being modified when you test your application) is overwritten every
    time that you build your project. For more information, see How
    to: Manage Local Data Files in Your Project.
    Fernando (MCSD)
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects
    and unknown namespaces.

  • 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

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

  • Need some samples to make Entity framework interact with WPF

    HI guys,
    I need to create an app which will query all details about customer from very big database for different search crieria. I don't have any sp to call individual section details of customer. so i planned to go with Entity framework and WPF. Both are new to
    me.
    Could someone please help me  with creating good WPF application (beautiful look and feel) & entity framework interaction with DB?
    or any other to make this requirement in an easy way with latest technologies.. All i need some good UI for searching customer details..
    thanks in advance
    Regards
    bala
    Balamurugan

    I (obviously) agree my sample is something to look at.
    Since it's the first in a series rather than a complete guide it cuts a number of corners.
    One to emphasise is that I almost never allow a user to edit in a datagrid directly.
    I either use popups so they are forced to work on one record at a time.
    Or I have a different usercontrol for a particular task a user does - like raising an order say.
    The second in the series is on the way.  Not sure when exactly but next month.  I have the code ready but I've not written the article for it yet.  Depending on your timescales you might find that useful.
    Also read this:
    http://social.technet.microsoft.com/wiki/contents/articles/26673.wpf-collectionview-tips.aspx
    That explains some dynamic filtering on the client and touches on a way to haul bits of a HUGE set of data onto the client.
    You definitely don't want to do that all at once.
    The thing to emphasis is you should always be looking to give the user a subset to look at.
    Think in terms of  a maximum of 200 to 300 records at a time in a datagrid.
    Linq with EF offers pass through queries.
    You will almost certainly want to use that feature in order to pick all the customers starting with the letter A or in town xyz or whatever.
    You use  linq on the client and it is turned into sql on the database.
    One thing which is sort of odd about linq is that the sql is generated when you iterate a collection.  That has an odd benefit which is great for flexible querying.
    You can base one linq query on another and chain your various criteria together.
    That only generates sql when you use that end result.
    Hope that helps.
    Recent Technet articles:
    Property List Editing;  
    Dynamic XAML

  • 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

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

  • Unable to Update .mdf using Entity Framework

    I am trying to insert Data in an .mdf file using Entity Framework but there is no data saved in the database. (I am using VS 2013)
    Code against the button is
    private void BtnSubmit_Click(object sender, RoutedEventArgs e)
    Product record = new Product();
    record.ProductName = txtProductName.Text;
    AzadIndustryEntities1 Db = new AzadIndustryEntities1();
    Db.Products.Add(record);
    Db.SaveChanges();
    MessageBox.Show("Record Inserted");
    samEE

    My problem is solved. Going to explain it so that it could help others also.
    As the default property of .mdf file Copy to Output Directory is
    Copy always so when we debug our program a copy of the .mdf file is copied in the
    debug folder which is in the bin folder  (Select
    Show All Files in Solution Explorer to view the bin folder) so, whatever changes we make in database through
    code it is saved in the copied .mdf that is in the debug folder. When we
    debug our program again the same steps are performed again and the previous database is
    overwritten. To prevent such happening the property of .mdf file mentioned above should be set to
    Copy if newer so, if there is any change in the model only then the .mdf will be overwritten
    samEE

  • Adding Entity Framework Crashes Visual Studio 2010/2013

    I'm having problem with using the Entity Framework version 6/5.  Whenever, I create the new solution and try to use the Entity Framework, Visual Studio crashes and restarts itself.  Scenarios are:
    1) Add Entity Framework by Add New Item-> Entity Framework-> go through wizard and finish...Crash.
    2) Add by Nuget console-> Install-Package Entityframework...Crash.
    3) Reload the solution from either #1 or #2, run Nuget console->Uninstall-Package Entityframework...Crash
    4) new solution, nuget package manager, select Entity Framework->Install...Crash.
    No matter what I do, and how I try to install entity framework, it keeps crashing on both VS 2010 and VS 2013.  It's frustrating when I'm trying to learn the technology.  Below are the Application error log I see in the Event Viewer:
    Log Name:      Application
    Source:        .NET Runtime
    Date:          4/29/2015 9:51:25 AM
    Event ID:      1025
    Task Category: None
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      DETROIT189L.HMMNA.COM
    Description:
    Application: devenv.exe
    Framework Version: v4.0.30319
    Description: The application requested process termination through System.Environment.FailFast(string message).
    Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    Stack:
       at System.Environment.FailFast(System.String)
       at System.Management.Automation.WindowsErrorReporting.FailFast(System.Exception)
       at System.Management.Automation.CommandProcessorBase.CheckForSevereException(System.Exception)
       at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(System.Exception, System.Type, System.String, Int32, System.Reflection.MemberInfo)
       at DynamicClass.CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, System.Object, System.Object, System.Object, Boolean, Int32, System.Object, System.Object, System.Object, System.Object)
       at System.Dynamic.UpdateDelegates.UpdateAndExecute9[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Runtime.CompilerServices.CallSite, System.__Canon, System.__Canon, System.__Canon,
    Boolean, Int32, System.__Canon, System.__Canon, System.__Canon, System.__Canon)
       at System.Management.Automation.Interpreter.DynamicInstruction`10[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon)
       at System.Management.Automation.DlrScriptCommandProcessor.RunClause(System.Action`1<System.Management.Automation.Language.FunctionContext>, System.Object, System.Object)
       at System.Management.Automation.DlrScriptCommandProcessor.Complete()
       at System.Management.Automation.CommandProcessorBase.DoComplete()
       at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)
       at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object, System.Collections.Hashtable, Boolean)
       at System.Management.Automation.PipelineOps.InvokePipeline(System.Object, Boolean, System.Management.Automation.CommandParameterInternal[][], System.Management.Automation.Language.CommandBaseAst[], System.Management.Automation.CommandRedirection[][],
    System.Management.Automation.Language.FunctionContext)
       at System.Management.Automation.Interpreter.ActionCallInstruction`6[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon)
       at System.Management.Automation.PSScriptCmdlet.RunClause(System.Action`1<System.Management.Automation.Language.FunctionContext>, System.Object, System.Object)
       at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
       at System.Management.Automation.CommandProcessorBase.Complete()
       at System.Management.Automation.CommandProcessorBase.DoComplete()
       at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)
       at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object, System.Collections.Hashtable, Boolean)
       at System.Management.Automation.PipelineOps.InvokePipeline(System.Object, Boolean, System.Management.Automation.CommandParameterInternal[][], System.Management.Automation.Language.CommandBaseAst[], System.Management.Automation.CommandRedirection[][],
    System.Management.Automation.Language.FunctionContext)
       at System.Management.Automation.Interpreter.ActionCallInstruction`6[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon)
       at System.Management.Automation.DlrScriptCommandProcessor.RunClause(System.Action`1<System.Management.Automation.Language.FunctionContext>, System.Object, System.Object)
       at System.Management.Automation.DlrScriptCommandProcessor.Complete()
       at System.Management.Automation.CommandProcessorBase.DoComplete()
       at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)
       at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object, System.Collections.Hashtable, Boolean)
       at System.Management.Automation.PipelineOps.InvokePipeline(System.Object, Boolean, System.Management.Automation.CommandParameterInternal[][], System.Management.Automation.Language.CommandBaseAst[], System.Management.Automation.CommandRedirection[][],
    System.Management.Automation.Language.FunctionContext)
       at System.Management.Automation.Interpreter.ActionCallInstruction`6[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon)
       at System.Management.Automation.DlrScriptCommandProcessor.RunClause(System.Action`1<System.Management.Automation.Language.FunctionContext>, System.Object, System.Object)
       at System.Management.Automation.DlrScriptCommandProcessor.Complete()
       at System.Management.Automation.CommandProcessorBase.DoComplete()
       at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)
       at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object, System.Collections.Hashtable, Boolean)
       at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
       at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()
       at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
       at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
       at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
       at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
       at System.Threading.ThreadHelper.ThreadStart()
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name=".NET Runtime" />
        <EventID Qualifiers="0">1025</EventID>
        <Level>2</Level>
        <Task>0</Task>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2015-04-29T13:51:25.000000000Z" />
        <EventRecordID>29379</EventRecordID>
        <Channel>Application</Channel>
        <Computer>DETROIT189L.HMMNA.COM</Computer>
        <Security />
      </System>
      <EventData>
        <Data>Application: devenv.exe
    Framework Version: v4.0.30319
    Description: The application requested process termination through System.Environment.FailFast(string message).
    Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    Stack:
       at System.Environment.FailFast(System.String)
       at System.Management.Automation.WindowsErrorReporting.FailFast(System.Exception)
       at System.Management.Automation.CommandProcessorBase.CheckForSevereException(System.Exception)
       at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(System.Exception, System.Type, System.String, Int32, System.Reflection.MemberInfo)
       at DynamicClass.CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, System.Object, System.Object, System.Object, Boolean, Int32, System.Object, System.Object, System.Object, System.Object)
       at System.Dynamic.UpdateDelegates.UpdateAndExecute9[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Runtime.CompilerServices.CallSite, System.__Canon, System.__Canon, System.__Canon,
    Boolean, Int32, System.__Canon, System.__Canon, System.__Canon, System.__Canon)
       at System.Management.Automation.Interpreter.DynamicInstruction`10[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon)
       at System.Management.Automation.DlrScriptCommandProcessor.RunClause(System.Action`1&lt;System.Management.Automation.Language.FunctionContext&gt;, System.Object, System.Object)
       at System.Management.Automation.DlrScriptCommandProcessor.Complete()
       at System.Management.Automation.CommandProcessorBase.DoComplete()
       at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)
       at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object, System.Collections.Hashtable, Boolean)
       at System.Management.Automation.PipelineOps.InvokePipeline(System.Object, Boolean, System.Management.Automation.CommandParameterInternal[][], System.Management.Automation.Language.CommandBaseAst[], System.Management.Automation.CommandRedirection[][],
    System.Management.Automation.Language.FunctionContext)
       at System.Management.Automation.Interpreter.ActionCallInstruction`6[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon)
       at System.Management.Automation.PSScriptCmdlet.RunClause(System.Action`1&lt;System.Management.Automation.Language.FunctionContext&gt;, System.Object, System.Object)
       at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
       at System.Management.Automation.CommandProcessorBase.Complete()
       at System.Management.Automation.CommandProcessorBase.DoComplete()
       at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)
       at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object, System.Collections.Hashtable, Boolean)
       at System.Management.Automation.PipelineOps.InvokePipeline(System.Object, Boolean, System.Management.Automation.CommandParameterInternal[][], System.Management.Automation.Language.CommandBaseAst[], System.Management.Automation.CommandRedirection[][],
    System.Management.Automation.Language.FunctionContext)
       at System.Management.Automation.Interpreter.ActionCallInstruction`6[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon)
       at System.Management.Automation.DlrScriptCommandProcessor.RunClause(System.Action`1&lt;System.Management.Automation.Language.FunctionContext&gt;, System.Object, System.Object)
       at System.Management.Automation.DlrScriptCommandProcessor.Complete()
       at System.Management.Automation.CommandProcessorBase.DoComplete()
       at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)
       at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object, System.Collections.Hashtable, Boolean)
       at System.Management.Automation.PipelineOps.InvokePipeline(System.Object, Boolean, System.Management.Automation.CommandParameterInternal[][], System.Management.Automation.Language.CommandBaseAst[], System.Management.Automation.CommandRedirection[][],
    System.Management.Automation.Language.FunctionContext)
       at System.Management.Automation.Interpreter.ActionCallInstruction`6[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon,
    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)
       at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon)
       at System.Management.Automation.DlrScriptCommandProcessor.RunClause(System.Action`1&lt;System.Management.Automation.Language.FunctionContext&gt;, System.Object, System.Object)
       at System.Management.Automation.DlrScriptCommandProcessor.Complete()
       at System.Management.Automation.CommandProcessorBase.DoComplete()
       at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)
       at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object, System.Collections.Hashtable, Boolean)
       at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
       at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()
       at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
       at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
       at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
       at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
       at System.Threading.ThreadHelper.ThreadStart()
    </Data>
      </EventData>
    </Event>

    Hi Hiroaki Morikawa,
    >>Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    Based on the error message, I doubt that it is the memory performance issue, like this case:
    http://social.msdn.microsoft.com/Forums/en-US/71f134bd-d665-43b5-8c67-52c4d6ed4ed9/kinect-driver-problem?forum=kinectsdknuiapi.
    Please restart the system, stop all unnecessary third party processes, and make sure that your task manager is free,  then test again.
    Do you install the VS2010 and VS2013 in the same machine? If so, please also make sure that your machine has the enough configurations. To make sure that it is not the add-in issue, please also run your VS in safe mode, or run your VS as the admin, test
    it again.
    Best Regards,
    Jack
    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

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

Maybe you are looking for

  • Can't see files/folders on server from windows

    i'm not sure if this is related to the ACL issue (not being properly honored in Samba on Leopard), but i'll explain my problem and hopefully someone can point me in the right direction i've set up file sharing with my server on several Macs and a cou

  • Elements 9 Organiser Thumbnails

    Hi All Im new to this forum. So would apprecite your help greatly. I've been running this version of elements for 4 years now with no problems until recently. When i open organiser now instead of seeing rows of small thumbnails as i used to i just ge

  • Cover flow is distorted, pixelated, in itunes for Windows XP.

    I feel like a chode posting on Apple forum...PC's suck, but I'm too stubborn to change over. Anyway, I did a clean install on Windows XP w/ service pack 2 and also re-installed itunes 7. The album artwork is displayed in the lower left corner and als

  • Diff. between running java code in a single processor vs multiprocessor

    Hi, This is a general question and I tried to find answer for it, but couldn't find so came here as usual. When designing a new Java project do we need to consider whether the application will be running in a single processor/multi processor. Does ou

  • ImportTextData fails with an error: row not found

    In am using Acrobat XI.  In a js script in an action wizard the statement this.importTextData("mypath", 0) continues to return a 3 "error: row not found".  I have checked the path and it is correct.  The text file was created by Access 2013 and is ta