Table not being displayed in Entity Framework Diagram (edmx) - asp.net-mvc

I have an ASP.NET MVC app built using NET 4.5 and Entity Framework database first. I am using Visual Studio 2013.
Now I am trying to update the edmx from database. Basically I am trying to add a table to the edmx diagram so I follow below steps:
Open edmx diagram from Visual Studio
Choose the option to update diagram from database
Navigate to 'Add' Tab in order to add the table, but table is not being shown there..... Also the auto-generated cs file does not exist in the folder.
So I go to Update Tab, and I can see that table is being shown there, however table is not being shown in the diagram.
So I decide to open edmx file using an editor and I remove all the entries for that table (It seems like somebody deleted the table in the past but entries in the edxm were not removed and they still were there). Anyway, after that I follow below steps:
Open edmx diagram again
Choose option update from database and go to Add Tab. Now table is shown there.
Select the table I am interested in
Press button finish to proceed to update the edmx diagram.
Now I look for the table into edmx diagram but table is not there, it is not being added... and the auto-generated cs file does not exist in the folder.
So how can I add the table to the edmx diagram?

Related

Entity Framework - Not able to add edmx file in MVC project

I am using VS 2015 and created MVC project. Now I have created tons of edmx files with SQL server database but I am facing issue with MySQL database.
At certain point, wizard got disappear and not able to add edmx file to project.
In above picture, after selecting EF Designer from Db, I select connection.
then i come to this screen and as i press next button, it just got disappear and nothing is happening.
I dont know if its problem with VS 2015 or something else?
Really need help with this.

Entities cannot be found after update edmx file

For the project I am working on, we have updated the database with two extra datatables that I now would like to add to the edmx file, but this gives an unwanted result.
What I do is open the edmx file, open the model Browser and run Update form database. In the wizard here I choose the two tables I want to add under the add tab and click finish.
The tables show up in the diagram view and in the Model browser under Model.Store-Tables/Views (and under Entity Types and EntityContainer). So far so good.
When I then save the changes to the edmx, all other existing entities,as well as the complete content of the Model.Context.tt file are deleted. The result being that the context entity and all underlying entities no longer can be found.
I do not understand why this is happening, and I don't know how to fix this and I am now stuck in the development of the project. i am using VS2015 and Entity Framework 6. I have spend most of the day to find a solution, but have not been able to do so. None of the "Entity can't be found" solutions around fixed my problem. I hope therefor that some smart minds here can help.
Thans!

App_Data folder is not checked in with Team Foundation Server [duplicate]

I am working with ASP.NET C# MVC 5.
.mdf/.ldf files in App_Data do not appear on Pending Changes in team explorer. Therefore I can't check them into TFS(visual studio online). I've tried recreating the project a few times and none worked. What might be the cause for this?
Go to Team Explorer and locate Excluded Changes and you should find it excluded. Right click the App_Data folder and include it.
But you might want to reconsider including the database files. As you're developing and testing, every little database interaction will trigger a change and most of those are trivial. Also, if someone else is working on this project, they may not want your database file to overwrite theirs when they Get Latest Version.
If you're using Entity Framework Code-First, the database is automatically generated when you build the project I believe, otherwise you just run the Update-Database command to do it. This lets everyone collaborating have their own local database file to work with. You can also utilize migrations to make updates to the database structure. If you want the database to be generated with pre-populated data, you should utilize the Seed method.
This is a general question. As already answered by 'Ty Morrow' in above comment there is an initial Seed Method in Entity Framework which ensures that all values are inserted. However there are many scenarios that you also need to work with the latest added / removed DB entries not present in the seed method.
Please perform the following steps to ensure that your data directory file is included in the source control.
Click App_Data folder and on encircled toolbar click on Show All Files as shown below in the snapshot
Right Click on your MDF (Data Source) File and click on Include in Project
Right Click again on your MDF File and click on Include in Source Control
Simply Check in the file by Right Clicking on root project folder link and file show be now part of Source Control

How Do I Re-Open the Entity Framework 6.1 Wizard to Add More Tables?

I have an Entity Framework 6.1 'Code From Database' based project and now I need to add more tables from the database to my code.
I've spent an hour now trying to figure out how to open the Wizard to add more tables to my project.
Am I missing something or are we not able to modify a 'Code from Database' project to bring in more tables?
You can add a new item to your project: Visual C# -> Data -> ADO.NET Entity Data Model. Select Code First from Database, select the objects needed and it will generate a model class (DBSets, Fluent config, etc) and the POCOs. I've got a big database I've been bringing over in chunks that way. https://msdn.microsoft.com/en-us/library/jj200620.aspx
There is no option to edit an existing 'Code from Database' import. I ended up creating the new POCOs by adding a new data model and then deleting the newly created DbContext after moving it's DbSet<> properties into my existing DbContext.
This was quite easy to do but I was only adding a couple of tables.

Moving entities between configurations in Xcode Data Model Editor

I'm currently working on an app which, will hopefully, use Core Data to store/retrieve data from 2 sqlite files (At the moment it just uses 1). I realise to do this I have to create another configuration in the Core Data Model Editor of Xcode which I have done. Now, I am trying to move entities from my current configuration into the new one but I cant find a way of doing it. I'm using Xcode version 4.5.1.
Am i doing this right? How do you move move entities between configurations?
Any help is much appreciated :)
Select one configuration in the left pane of the model editor and then drag'n'drop one or more of its entities from the right pane to another configuration in the left pane. This will copy the entity, so you still need to delete it from the original configuration.
This worked for me in Xcode 7.2.1:
Display the source model, select the source entity, select Edit menu/copy.
Display the target model. In the Entities pane Add Entity (+) for new entity.
Select the new entity and click Edit menu/paste.
I know of two approaches depending on how many entities you need to transfer.
If you want most or all of the entities to be copied, you can copy and rename your existing xcdatamodel in the Finder, then add the new file to the project. I've done this as a test, but since I'm only working with a single versioned model, I haven't gone through to production with a model entered this way, so I don't know if there are any downsides.
If you only have a few entities to transfer, simply select the entity in one model, copy it (command-c), then select the other model and paste it (command-v). This only works for one entity at a time and you need to do some clean-up afterwards, but it's still better than manually re-entering all of the properties. After copying, update the following in the new model, which don't transfer over cleanly:
Relationship targets and inverses.
Relationship delete rules.
Parent entities.

Resources