Visual Studio 2013. dbml file not updating - c#

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.

Related

How to "connect" a SQLite DB to gridview?

I'm trying out making websites with C# and I have a problem with my SQLite DB.
I've seen that you can Display every element of a DB with a gridview and it is automatic. But I cannot make it work with SQLite.
So I searched to find a solution to my problem and I found an article going through the process but it's a bit outdated.
He installed the System.Data.Sqlite(x86 x64) and I was trying to find that one but I couldn't find it.
But I found System.Data.Sqlite.x64 and I assume that it's the same and that it just doesn't support x86 anymore.
Nuget
Afterwards he opened the Entity Data Model and he had 2 options instead of 4 as me and also not the same ones.
I clicked on the EF Designer from database cause it had somewhat the same description as the one he clicked on.
Entity Data Model Wizard
After I click next I go to the Choose Data Source but I don't have an option for SQLite.
Choose Data Source
If I'm doing something wrong or I didn't understand something please correct me.
Thank you for your time!
Seems like this was raised with Visual studio community: sqlite-data-connection-not-appearing-in-server-exp
Solution proposed is the following:
Hi Robin,
It appears the developer that created the SQLite/SQL Server Compact Toolbox also has a solution to support VS 2017. See https://github.com/ErikEJ/SqlCeToolbox/wiki/EF6-workflow-with-SQLite-DDEX-provider
Or you can get the extention from the marketplace here
Works with
Visual Studio 2012, 2013, 2015, 2017, 2019

shared project and database

I have a visual studio project and I want to use it on another computer. I found that there is a way to upload the project but I wanted to know if its possible to share also my database so it will be linked to the project anytime I change the computer Im working with, and the database will update itself on both computers.
?
create a database project along with your c# project and put all your tables, stored procs, etc. in it. check in the database project in your version control. when moving to a new computer "publish" the database project the first time, or do a "sql compare" any consecutive time to apply the db changes.
https://msdn.microsoft.com/en-us/library/hh272677(v=vs.103).aspx
https://msdn.microsoft.com/en-us/library/hh272690(v=vs.103).aspx

Visual Studio 2013 error creating an EDMX file

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.

Unable to add tables in the empty database in visual studio ultimate 2012 using graphic user interface

I just want to make a very simple database in microsoft visual studio.
What I did?
1. I created new project in C# as WindowsFormApplication (created default code, I didn't change it, because I am interested in making the database only, so no source code).
2. Then on the Solution Explorer Panel of Visual Studio, I right clicked on the application and clicked on Add -> New Item.
3. Then I selected Service Database.
4. The database is created.
5. I go to server explorer and expand the database and tabled, then i see there is no table.
6. I right click on tables and then I click add new table and I get this error
"Object reference is not set to instance of an object"
There are plenty of answers for this error on stack overflow and other sites but nothing helped me.
I reinstalled Management Objects and Compact 4.0 ... still nothing.
My OS is windows 7. 64 bit operating system.
Visual Studio Ultimate 2012
I really need to make a test database.
I enabled the disabled services from task manager and then reinstalled everything and worked fine.

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.

Categories

Resources