Last post Jun 26, 2015 01:08 PM by maggiemays
Jun 16, 2015 05:36 PM|maggiemays|LINK
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 ?
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.
Jun 18, 2015 04:09 AM|Li Wang|LINK
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.
Jun 18, 2015 10:59 AM|maggiemays|LINK
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.
Jun 19, 2015 04:16 AM|Li Wang|LINK
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
Jun 19, 2015 12:52 PM|maggiemays|LINK
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.
Jun 24, 2015 04:35 AM|Li Wang|LINK
Have you tried as the article mentioned, have you solved your issue?
Jun 24, 2015 05:23 PM|maggiemays|LINK
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.
Jun 25, 2015 02:20 AM|Li Wang|LINK
Which verison of entity framework and visual studio do you use?
Jun 26, 2015 01:08 PM|maggiemays|LINK
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