Making a C# SQLite Database first model appear out of thin air - c#

I am trying to make a tiny application, using SQLite and EF6.
I already have an SQLite database with tables and data, so I want to create a model and populate it from that. However despite everything I've tried I have had no success.
When adding a new "ADO.NET Entity Data Model" I have no option for SQLite database (this is on Visual Studio 2015).
I already saw this, this and this.
What I have done so far:
- First tried to simply install SQLite by NuGet - no luck.
- Then I created a new project, and instead of NuGet installed the latest x32 System.Data.SQLite setup package and made sure to check the option of installing design-time components for Visual Studio 2015 - no dice
- Then I saw someone had luck with installing an older version of the setup packages. After a painstaking installation (after removing the newer version) - no cigar.
- So I started following this one and, hooray - I can't add the assemblies, despite telling the setup to put them in the Global Trash Can or whatever.
So I come to you, dear people, hoping someone can wave a magic wand and help me get this thing that's supposed to be tiny, fast and easy to be, you guessed it - at all working.

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

Connect to Oracle database from asp.net core

First off I have read other posts about connecting to an Oracle database, unfortunately they could not help me. I'll describe what I have tried and hopefully someone can point me in the correct direction.
First off I tried to install ODTwithODAC122010 as many sources are saying,but this one gives me a few process exited with non zero exit code. It says it's successful but nothing seems to be changed.
Next to that I tried installing ODTforVS2017_122010.exe I have an updated Visual Studio professional. It says the installation is a success. This however does not seems to add any option like tutorials describe. With this I mean that there should be something visible in;
visual studio tools -> connect to database -> Oracle database, data provider menu should have something like Oracle for.. This doesn't show up unfortunately..
So I tried connecting to the database in my visual studio project selecting the .net framework data provider for oracle. Here three fields are asked: Server name username and password. I tried filling them in but it couldn't connect.
For server name I used: IPADDRESS:PORT/SERVICENAME
After that I gave up hope for connecting to the database through visual studio (I can connect to the database using oracle SQL developer).
Then I installing the following nuget packages:
- Oracle.ManagedDataAccess
- System.Configuration.ConfigurationManager
- System.Security.Permissions
- System.Security.Principal
And wrote a piece of code to connect to the database like:
using(OracleConnection connect = new OracleConnection(ConnectionDetails.returnConnectionString()))
{
connect.Open();
Console.WriteLine("did it work?" + connect.ServerVersion);
}
Where returnConnectionString returns:
"User Id=MYID;Password=MYPASSWORD;Data Source=IPADDRESS:PORT/SERVICENAME"
Unfortunately when I try to run this I'm facing a ExecutionContext.cs not found. This is happening at connect.open();
I'm launching this code at:
public static void Main(string[] args)
{
var a = new DatabaseConnector();
a.test();
BuildWebHost(args).Run();
}
As I final word I want to make it clear that I'm using ASP.NET Core and that your suggestions and help will be greatly appreciated!
To be precise,
Right click on your project
Go to Manage NuGet packages
Search for Oracle.manageddataaccess.core . You will get Nuget package 2.12.0-beta2 version. Add it.
In the page, import as below to access oracle classes
using Oracle.ManagedDataAccess.Client;
This is a beta version of Oracle data access provider and PROD version is supposed to be available at the end of 3rd quarter of 2018.
There's currently no ODP.NET support for .NET Core, it was suppose to be released last year, but there's been no news more than and it's coming tweet from the ODP twitter account a couple of weeks ago.
You can make the current version work by moving your project from .netcoreapp2 to a net461 or higher target framework, but it would remove the cross platform support from your project.
In order to move your project to .net461 or any other follow this steps:
Edit your csproj file and replace the TargetFramework with net461
If you have a web project then remove the Microsoft.AspNetCore.All package and install the Microsoft.AspNetCore (which should download the others dependencies).
At the time of asking this question there was no driver Roy Sanchez answered that. A few weeks the driver got released on the oracle site and a as a nuget package.

Visual Studio error when I right click UWP project not finding framework

I am having the exact same issue/error as this post from yesterday. Similar SO Post
SIDE NOTE...As you can see, I am new and therefore, only have 45 reputation. As such, I could not simply add a comment to the above existing post and had to create a whole new post even though they are the same issue....seems silly. But I digress....
I wanted to provide additional comments in the hopes to get an answer. My issue started suddenly the a few days ago. I made no major changes to references, VS updates, etc... However, when I right click my csproj in visual studio, I get the error and I have to click it five times before it goes away, at which point I finally get the menu.
Again, I have made no major changes BUT I went ahead and confirmed that:
My target version and Min version is Windows 10(10.0; Build 10586). That is the SDK version that I have installed and am using.
I verified that my NuGet updates are complete and that my Microsoft.NetCore.UniversalWindowsPlatform are installed and update to date (5.2.2 as of now).
I do have a reference also to "Universal Windows". This was created automatically when I created my project and I cannot remove this reference but it is there. When I select it, I do see that it is "UAP,Version=10.0.10586.0" so this should be good. I do notice a possible issue here. Again, this reference was created for me and I cannot remove or change it. However, it is pointed to a folder named
C:\Program Files(x86)\Windows Kits\10\References\Windows.ApplicationModel.Calls.CallsVoipContract\1.0.0.0\
Why did the Windows Universal reference default to that folder and only that folder? I am not using VoIP so I wonder why it chose this one? Also, what if I need some of the other references in the References folder?
I created a brand new Windows Universal project and the same error happens on a fresh project.
Please help, it is annoying. Project still seems to build and work fine though.
Thanks!
I found the issue in my case, it was an extension that I added on to Visual Studio provided by SyncFusion (which their installer actually creates 7 or se extensions in Visual Studio). After troubleshooting my issue and doing some of the same things to resolve (repairing .Net, SDK, Visual Studio) I then thought about the error a bit more. While it is cryptic (and has poor english "An Exception has been occured") these are all clues that it could be any of the frameworks that I have installed via extensions as well.
I also had another clue, the issue started happening a few weeks ago, around the time I updated my SyncFusion controls to the latest version.
So, I went to Tools > Extensions and Updates. I went to Installed > All and found all of the SyncFusion items (there are several) and disabled them all. After I disabled them, and restarted Visual Studio, the problem went away!!!
This is a workaround for now. In the meantime, I put in a support ticket with SyncFusion on the issue. I will certainly update this thread when I get a response from them. Also in the meantime, I then went back and re-enabled each of them again, one at a time, to see who the real culprit was. In my case it was the SyncFusion Web Conversion and Migration extension.
If any of you are not using SyncFusion but having odd Visual Studio issues such as this, I suggest doing something similar by going through your extensions and disable any that you added on, starting with the most recent add ons, especially if they were added around the same time you started having the problem until you find the culprit.
Hope this helps!

Visual Studio ASP.NET Template Incomplete (MVC)

I got really weird problem. I am starting to learn MVC but my ASP.NET template seems to be incomplete and does not support MVC at all. It doesn't matter which version of .NET Framework I choose. Look:
What is more weird, my ASP.NET MVC 4 Template from previous version of visual studio works fine, without any issues (I can add views, controllers etc). BUT ONLY if I choose .NET Framework lower than 4.5.2.
What I already did:
I tried command: devenv /installvstemplates
I did repair installation of visual studio and its updates
I uninstalled all addons and extensions
What I do not want to do:
I dont want to clean reinstall Visual Studio
What I think I can do to fix this:
copy cache from someone and paste it to my \Common7\IDE, but I do not
have access to working cache files.
I would really appreciate your help guys.
/edit (I am sorry for my mistake with adding answer)
So I tried to fix it as i didn't receive any answer, I tried many things from google results, many pointing to this site but nothing worked.
I uninstalled visual studio, cleaned registry, used /uninstall /force with 2012, 2013 and all updates isos with no luck.
I tried this solution:
Can't create new MVC5 project or any other ASP .NET projects in Visual Studio 2013
but it didn't work either.
Does anyone has any idea? I will give you some reward if your answer help me.
I would really appreciate anything. Point me to some direction.
ONLY MVC 5 doesn't work, no templates are shown (in one asp.net
template) and if I download mvc 5 template from the web, or convert
my existing mvc 4 project to mvc 5 it stops showing "add controller,
add view options"
All MVC 4 projects and templates are working without any issues at all.
/edit 2
=== WORKAROUND ===
If someone tries to resolve this issue, basically I coudn't do it, but I found workaround which is ugly and simple:
Deleted every single extension AND every VS Update
Uninstalled Visual Studio
Uninstalled it again using /force method
Cleared its every trace and the registry traces I was able to found
Used TuneUp utilities to clear broken registry keys
Uninstalled SQL Server 2014
Uninstalled everything that was related to Visual Studio (Web Essentials, .Net Frameworks, Command Tools etc), check in Ccleaner,
it will be much faster.
Installed Visual Studio with Update 3 and... It was broken right after installation, missing files errors
I repaired the installation and everything seemed to work but... localization, language files didn't work, caused visual
studio to
show errors or simply hang.
I tried to reinstall language pack but I received error "this language is already installed". I couldn't uninstall it
either. I finally added language files manually:
in VS folder in Program Files searched for '1033' and 'en' folders
opened my acronis partition backup
added to every directory where one of the two folders was found, folder equivalents of my language '10xx' or 'xx'
WARNING: If you won't do it for EVERY folder, you will get assembly missing error, or your visual studio will have spikes (especially in .aspx files). Don't copy paste it all at once either cuz if you place localization files for assemblies, extensions you don't have, it will cause errors too.
TIP: If you don't have backup, simply take this files from someone else, they should generally work, no matter which update VS of the other person have.
Its unfortunate that no one had better answer for me but I do hope that this will at least help guys in similar situation.

LINQ on DataTable

I have a rather confusing issue.
I've recently picked up some code I wrote 8 months ago in VS Web Developer 2008. Ive now moved on to 2010, so I upgraded the project, but otherwise it's the same. It now won't build because of code like below:
IMSDataSet.vwPartDataTable table = new IMSDataSet.vwPartDataTable();
da.Fill(table);
//Convert to Parts
return table.Select<IMSDataSet.vwPartRow, Part>((row) => { return new Part(row); }).ToArray();
Where vwPartDataTable is created using the Data Set designer in Visual Studio.
Now having a look around on SO it appears that this is incorrect code, and I need a AsEnumerable() in there. However the thing is. I deployed this code. There's load of these lines, I used them everywhere, so it must have worked.
The project upgrade moved everything to .NET 4.0, but putting it back to 3.5 had no effect.
Can anyone shed any light. I'd prefer to keep the code exactly as it was because that is what the customer has.
Thanks.
If that was a .Net 2.0 feature, you can target that framework version in Visual Studio 2010 if you take an extra step described in this popular SO question.
To answer this. I had incorrectly installed some SQL component. I got an error when trying to open my .xsd (the drag-and-drop data table designer), involving a missing package. This fed down into the custom tool generating old or basic code that didn't include generics support, therefore the generic LINQ functions I used weren't available.
Fixing this required uninstalling Visual Web developer and .NET 4, then re-installing. I also installed SQL Server 2008 R2 express separately instead of letting the Visual Web Developer (VWD) installer do it. This is what I've done previously as well.

Categories

Resources