locked
problem with duplicate objects in entity model RRS feed

  • Question

  • User632751675 posted

    hi,

    I wanted to include some stored procedures to my entity model, and I it seems fine, until I compile and I have duplicate objects and warnings about ambiguity.

    I see that I am createing another file, Context1.cs under Context.tt, while I have the original Context.cs file.   So, I thought I'd remove the context1.cs file to fix the issue, but then I am finding that I don't have the stored procedure I added.  How do I fix this?  How do I fix this problem ?   

    Thanks

    I found that I also had designer files that were duplicate.  I tried to remove the ones I didn't think I needed, but that didn't help. I also noticed that when I was going to update from model from the database , the first screen was for the database connection.  In the past, once it was set up it never showed again. I wonder if this is why the problem was created.
    I only have one database I'm working with.

    Tuesday, June 16, 2015 5:36 PM

All replies

  • User-84896714 posted

    Hi maggiemays,
    Thank you for your post.
    Did you add stored procedures like this?
    Right click project -> Add -> New Item -> ADO.NET Entity Data Model.
    This will create a new model for you.
    You could open your edmx file, and right click the space of the design interface.
    Choose update model Update Model from Database.
    Hoping my reply could be helpful to you.
    Best Regards,
    Wang Li

    Thursday, June 18, 2015 4:09 AM
  • User632751675 posted

    Yes, I chose to update model from database( right-clicking empty space).  I have tried several times, ending up with extra designer( designer1 ), context1  files.

    I know that I've added a stored procedure before without issue, but this time, I am unable to add anything to the model without generating these 'extra' files.

    I'm kind of stuck at the moment because I need these stored procedures.  Unless there's another way I can add a record to a table and return the key it generated so i can use it afterwards in my update process.  But, it seems that when you use this EF model, it would be best to have everything ready when you create the model in the first place.

    Thursday, June 18, 2015 10:59 AM
  • User-84896714 posted

    Hi maggiemays,

    I tested on my side, and it doesn't generate duplicate context, I use visual studio 2013 and entity framework 6.

    I found a similar post on ADO.NET Entity Framework and LINQ to Entities forums.

    You could check it and follow the practice suggested by JA Reyes.

    https://social.msdn.microsoft.com/Forums/en-US/8ce7aaaf-6a2f-4bca-969f-73e11ef47b2b/context-t4-creating-a-duplicate-context-class-called-context1cs?forum=adodotnetentityframework

    Best Regards,

    Wang Li

    Friday, June 19, 2015 4:16 AM
  • User632751675 posted

    I have more than just the context.cs file duplicated, so I am assuming I would rename the designer1,context1 and another file in order to set this right again.

    Friday, June 19, 2015 12:52 PM
  • User-84896714 posted

    Hi maggiemays,

    Have you tried as the article mentioned, have you solved your issue?

    Best Regards,

    Wang Li

    Wednesday, June 24, 2015 4:35 AM
  • User632751675 posted

    hi,

    I did try, but it didn't work for me.  I ended up deleting the model and recreating it. 

    I noticed that when I rename a function, I can't access the function by the new name, only the old one.  I still haven't figured that one out yet. It was working before.

    thanks for your help.

    Wednesday, June 24, 2015 5:23 PM
  • User-84896714 posted

    Hi maggiemays,

    Which verison of entity framework and visual studio do you use?

    Best Regards,

    Wang Li

    Thursday, June 25, 2015 2:20 AM
  • User632751675 posted

    version 5.

    I also noticed that when I 'update model from database', everything looks ok, then I get messages about  not being able to save changes to the edmx designer and some other file.

    I have tried several times to fix this, removing the model from the project and re-adding it, to no avail. It's really set me back and don't know how to resolve this.

    I changed my properties from 'none' to 'default'( properties on edmx file ), but it made no difference.  When I try to update from model,

    I get error:  tf14040 cannot change item, because it already has a pending change that is not compatible"... I have no idea how to fix , do you? thanks

    Friday, June 26, 2015 1:08 PM