Visual Studio 2013 error creating an EDMX file - c#

In Visual Studio 2013 (Update 2, and later Update 4), using Entity Framework 6.1.2, I am having issues when creating an EDMX file.
When creating the file, I add a new item, select "ADO.NET Entity Data Model", and regardless of whether I create an "Empty EF Designer model" or "EF Designer from database" (and regardless of which database I might chose if building off of a database) I receive a very generic error message:
"Operation is not valid due to the current state of the object"
and it kicks me back to the Add New Item wizard. The *.edmx is generated, but if I attempt to open the generated *.edmx file, I receive another generic message:
"The operation could not be completed."
The *.designer.cs file appears to be populated, but not all of the assembly references are added to the project; System.Data.Entity had to be added manually for references to System.Data.Objects to resolve.
I have installed Entity Framework 6 Tools for Visual Studio 2012 & 2013, for both versions of Visual Studio. I have tried performing this with the projects both bound to TFS as well as unbound, and the error persists in either situation.
If I open the solution in Visual Studio 2012, the same errors persist. I am able to add an *.edmx file in Visual Studio 2010 successfully, and then later open the project in Visual Studio 2013, and the *.edmx file is present and accessible; it opens and I am able to view it, but if I move or edit, I am given the following error:
"XmlModels involved in this transaction are not editable."
Does anyone have any suggestions for that is happening, or what might be missing from my environment? I'm at a loss for what is improperly set up on my system.

Based on the error "XmlModels involved in this transaction are not editable", I was able to track down a response to a similar issue:
Entity Framework Unable to refresh database tables under TFS 2010
In short, my project and solution were stored on disk at C:\Code\C#\Application\[etcetera]
The issue was the "#" character in the solution/project/file path. Quickly copying the solution to C:\Code\CSharp\[etcetera] solved the issue of both adding and editing an existing *.edmx file.
I am answering this to preserve the Wisdom of the Ancients.

Related

Visual Studio 2013. dbml file not updating

I am working on a Visual Studio project that uses ASP.NET/C# with LinqToSql.
All has been going fine, until some changes were made to one of the database tables.
After that, the Table in question was removed from the DBML database diagram, and the new version added back in using the Server Explorer.
Trouble is, VS2013 still does not see the new fields, and will not compile if I reference them. The new table structure is clearly visible in the DBML database diagram.
Right click on your file in solution explorer and select Run custom tools and see if it is getting updated.
Rebuild your project and you should see the changes.

ADO.NET Entity Data Model BUG

I have a project in visual studio ultimate 2010 (MVVM) and database, in SQLITE.
Everything worked fine, but now I have a problem with the ADO.NET Entity Data Model.
I searched for information about this and have not found much .. Every time I want to open the wizard, it just closes.
I think I should reinstall Visual Studio, but before doing so if anyone has had this error before and know what can be, I'd be grateful.
I've found this can be a bug with third party data adapters being left in strange states. Open your View > Server Explorer and remove your third-party data connections. Then, try opening the wizard again.
I had this problem with VS 2013 (Entity Model Wizard disappearing). I solved it by first uninstalling the MySQL .NET/Connector (I had 6.8.3) and installing it back, and then retrying the wizard. Wizard completes and I could select tables etc.
Try deleting the following file
c:\users\myusername\appdata\roaming\microsoft\visualstudio\10.0\SeverExplorer\DefaultView.SEView.
If you are creating a web application such as through MVC check the AttachDBFilename in web.config for characters such as |.
I had the same issue and was unable to resolve it by removing connections from Server Explorer.
I attached a visual studio debugger to visual studios.
Turned on CLI exceptions and turned off Just my Code.
I then saw the hidden exception.
The wizard was throwing an exception with the message "Invalid Character in Path" in System.IO.Path.CheckInvalidPathChars(string path, bool checkAdditional).
The value of path was "|DataDirectory|\\aspnet-Mvs4Dummy1-20140402113853.mdf".
I realised that this was the database that visual studios had automatically generated with my MVC application and that the offending character was probably the '|' symbol.
So I performed a Grep search of my directory and found that this was being stored in my web.config in this apparently unsupported format.
I changed the entry to a full local path and the wizard stopped disappearing.
Open VS,
View->Server Explorer and delete connections under the data connection files.
I had already this error before and solve it doing like this.
My solution for VS2015 was:
Install MySQL.NET Connector 6.9.8 to replace 6.9.5.
I already has installed MySQL for Visual Studio 1.2.6 and had got the appropratiate MySQL NuGet packages (MySQL.Data, MySQL.Data.Entity.EF6, MySQL.Web).
I solved the problem by doing some steps below:
1/ Open "Server Explorer" window in Visual Studio
2/ Delete all Connections under "Data Connections" sections
3/ Then, Add the ADO.net Entity Data Model as normal

Missing Entity Data Model in VS 2012

I cannot find the Entity Data Model under the 'Data' tab when adding a new item.
I have looked at several questions and answers, information on this and none of the solutions have worked.
I have repaired, uninstalled and reinstalled, installed the EF Tools package manually and tried uninstalling all VS related programs. I have also tried creating several new projects, Class Libraries, Web Projects under different .NET frameworks and it isn't there.
Main project: Visual Studio 2012, Class Library Project .NET 4.0
I updated Visual Studio 2012 using this link:
http://www.microsoft.com/visualstudio/eng/downloads#d-visual-studio-2012-update. After this update, the "Entity Data Model" option was added to the data tab.
The new Entity Data Model in VS 2012 by default uses T4 templates (.tt) files instead of former custom tool for code generation. The generated context is also based newer DbContext API instead of ObjectContext API used by Visual Studio 2010 (that is the reason why it doesn't have the method - the equivalent method in DbContext API is Set<T>). Both T4 and DbContext API are currently recommended approach for using EF.
I don't have VS 2012 on my current machine but what you can try is to delete both .tt and turn on the old generation as described in .Desinger.cs.
Edit: You may try to Re-install VS2012 and/or repair it. That should fix this issue. In addition, look at the release version of your VS2012.
Another suggested solution to re-install and reason why this happens - Unable to add Entity data model to a Visual Studio project
The accepted answer from here solved the problem in my case:
http://www.datazx.cn/Fv7p5a/xw-US/oaax2pu/2q7xs6/d8x6rssc-b4mt-fsix-bc6c-ct8mf8d6fsbc23rsdfd.html
I finally figured it out. I ran EFTools.msi from a C:\ProgramData\Package Cache\ subfolder, which only allowed me to 'uninstall' or 'repair'. I tried repair, but I get the same problem, so I did 'uninstall', then ran it again and it allowed 'install'. After this install, I can now add Entity Data Models.
Also, the accepted answer in the "Missing Entity Framework Template in Visual Studio 2012 Express for Web" threat on forums.asp.net suggests that repairing Entity Framework Designer for Visual Studio 2012 enu via 'Start -> Control Panel -> Programs and Features' might work as well (I can post only two links with my current 1 point StackOverflow reputation, so I won't provide the exact source).
Another possible solution:
My Problem was: Visual Studio is installed on Drive D:\, whereas the Entity Framework Installer placed the Package in c:...\VisualStudio 10.0\Common7....\ItemTemplates folder. --> Copied the AdoNetEntityDataModelCSharp.zip to drive d: and ran devenv /installvstemplates. This fixxed it for me. Edit: Also had to copy Various DLLs from IDE folder, PrivateAssemblies and PublicAssemblies. then run devenv /ResetSkipPkgs
http://social.msdn.microsoft.com/Forums/en-US/c059069b-eae4-48b4-a06e-ffd5f186077b/adonet-data-entity-model-template-missing-in-vs-2010-ultimate?forum=adodotnetentityframework
I also installed VS in a non-default path (different disk partition), so it indeed may be one of the potential causes of the problem.
You can right-click the designer surface and choose the model browser; Here is the only way to activate the Model browser in solution explorer.
The Model browser is included in VS 2012 recommended settings during installation.

After updating Entity Framework model, Visual Studio does not see changes

If I do any changes to my EF 5.0 model, VS does not seem to see the changes. I have tried adding a new table, which shows up fine in the model, but then if I try to use it somewhere the table does not show up in intellisense and I can't use it.
I have also tried changing datatypes of a column, which again shows up fine if I look at the .edmx model file, but visual studio will still give me compiler errors on that field because I am trying to assign the incorrect datatype.
If I delete the EDMX completely, and recreate it, then the changes work fine. but it is tiresome to regenerate from database each time when I should be able to just "update model from database" and rebuild.
I have never had these problems with EF before. Does anyone know the cause or the fix to this problem?
Thanks.
First Build your Project and if it was successful, right click on the "model.tt" file and choose run custom tool. It will fix it.
Again Build your project and point to "model.context.tt" run custom tool. it will update DbSet lists.
If this is the bug with the edmx file located in a folder it is now fixed - download and install VS 2012 Update 1. You can get it from: http://www.microsoft.com/visualstudio/eng/downloads#d-visual-studio-2012-update
This is apparently a bug in the Entity Framework that the model does not get updated when your Edmx file is located inside a folder.
The workarounds available at the moment are:
Install VS 2012 Update 1 which should fix the bug.
If you are not in a position to install Update 1, you will have to right click on the model.tt T4 template file and click run custom tool. This will update the classes for you.
Hope that helps someone out there.
Link: http://thedatafarm.com/blog/data-access/watch-out-for-vs2012-edmx-code-generation-special-case/
I also had this problem, however, right-clicking on the model.tt file and running "Custom tool" didn't make any difference for me somehow, but a comment on the page Ghlouw linked to mentioned to use the menu item "BUILD > Transform All T4 Templates." which did it for me
Right click the .tt file and select "Run Custom Tool", that should update it:
You should have a <XXX>Model.tt file somewhere which is the T4 template that generates your model classes.
If it is in a different project, it will not update when you save the edmx file.
Anyway, try right-clicking on it in Solution Explorer and choosing Run Custom Tool
I searched for this answer because I had a similar situation in VS2013. In my case, I found that a simple "Clean Solution" cleared out all the old definitions.
Are you working in an N-Tiered project? If so, try rebuilding your Data Layer (or wherever your EDMX file is stored) before using it.
I've also experienced this problem with none of the classes being generated under the model.tt file. In my case it was down to issues with how I had built the DB in SQL2012. I'd set a column in a table to nullable that was also a foreign key and although I think you should be able to do this it caused a problem in EF5.
As soon as this was cleared and the diagram updated from the database they reappeared.
EF5 VS2013
After Changing the laptop When I updating Entity Framework model, stored procedures are not seen in code
What I have done to make this working
Update visual Studio 2012 Update 5 (Not Working)
Update/Modify from Programs (Not working)
After update stored procedures, build the project again then go to context.cs, right click and run custom tool (Not Working)
Doing RND (Someone says the issue is due to some permissions in MSSQL) But unfournately I have done alot of permission in MSSQL but (Not Working)
Install 2019 and run the project. Now everything works fine
Conclusion
Visual studio 2012 have a bug (bug is resolved in Update 1, 2, 3 and 4)
Change the Visual Studio version will resolve the issue
I had this problem in EF 6 using Visual Studio 2022. I tried all of the things here plus cleaning and rebuilding the solution, deleting the stored procedure out of EDMX and the database and re-updating, closing VS, and restarting my computer. None of those things worked. What ended up fixing it was simply opening the DTSEF.vb file. When I did that, Visual studio found the missing properties in the result object.

EDMX doesn't show the UI designer - gets directly into the XML file

I've reinstalled my laptop - Windows 7, VS2010, VS2010 SP1, SQL2008 and SQL2008 SP2.
I've also done windows updates - no updates available from update window anymore
The issue I've is: When I double click on the EDMX file it gets directly in to the XML. Why is that?
I don't get any error....
I can't do update from Database or add entities from Database etc....
I googled and found you should do open with and choose XML and then close XML and double click again. I've tried several options (open with ) and I don't get the UI Designer for my Entity Framework (edmx ) file.
I clicked on the properties of the file (*.edmx)
and I see Cusotmtool: EntityModelCodeGenerator and build action : EntityDeploy
I then right clicked on EDMX and choose 'Run Custom Tool" and then I receive this error
"cannot find custom tool 'EntityModelCodeGenerator' on this system."
I checked VS2010 and VS2010 SP1 is installed. I did again install from DVD and choose REPAIR and I still have this problem....
so what could be problem?
thanks
you had unchecked some of recommended features while installing the Visual Studio. Just Reinstall the visual studio to configure the features. after installation open the .edmx file with the "ADO.Net Entity Framwork designer".
Try devenv.exe option /resetskippkgs, then solve the error.
The question is about VS2010, but if you're looking at the same problem on a newer Visual Studio (e.g. VS2013), you probably need to reapply the latest VS update (worked for me) or reinstall VS.

Categories

Resources