I know that Vertica has ADO.NET drivers. Has anyone tried to run Entity Framework on Vertica? If it doesn't work (expected) what might be involved in making it work. Any shared experience with this problem will be appreciated!
I have never tried Entity Framework with Vertica, however one piece of advice I can give you is that Vertica's connection handling is very similar to Postgresql. Very often if you can get your client-side to connect to Postgresql, it will connect to Vertica. So even if the ADO.NET drivers don't work out, using the Postgresql ones might. Look at this blog entry for more info.
Related
My company's main software application hasn't been updated in twenty years. I expect to soon be working on a complete rewrite of it. To that end, I am beginning to work my way through the book "Pro ASP.Net Core 3" by Adam Freeman (8th edition).
Our application was written to be independent of specific database types. Most of our customers use PostgreSQL, but a few use SQL Server. Therefore, we use ODBC because ODBC drivers exist for both of those databases, as well as several others. The application does not do anything fancy with the databases, and ODBC works well. We configure an ODBC DSN to talk to whichever database the customer has, and the application itself doesn't have to be changed.
A search on "Entity Framework Core ODBC" led me to the EF Core Github, where people have asked similar questions, and the answers were mostly along the lines of "why on earth would you want to do that?". Well, I need to do that.
Can I use EF Core with ODBC, or is there some other way that I can set up an Entity Framework Core application that does not have to be modified if the underlying database changes from PostgreSQL to SQL Server?
You could use your appsettings.json to store a value used to swap between the two. Those environment configs get reloaded on change (though you might have to restart your application to read them again, I'm not sure on that one).
Regardless something along the lines of this would suit your needs I think.
if (Configuration.GetSection("dbOptions")["postgres"]))
services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(Configuration.GetConnectionString("PostgresConnectionString")));
else
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("SqlServerConnectionString")));
EDIT: I placed this in Startup.cs where you would normally configure the DBContext. I use a similar solution reading off the Environment type to load either the Prod or QA connection strings based on deployment. In principle, this should accomplish the same task without the need for rebuilding and redeploying the code base.
This code:
ALTER DATABASE SCOPED CONFIGURATION
SET LEGACY_CARDINALITY_ESTIMATION=ON
makes my Entity Framework code generation very fast.
However I have also learned that I need to set it off my code generation completes.
Can some one explain what actually the code does? I went through google but could not find the understanding.
I am using SQL Server 2016 and Entity Framework v6
It looks like this is a known issue with new CE and the reverse engineering queries in EF. It also looks like the issue is specific to SQL 2016 and has bounced back and forth between the SQL team and the EF team.
The first fix posted was the one you mention in your post, ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION=ON
After this it looks like updating statistics on tables is a viable solution.
Check out this link - https://github.com/Microsoft/sql-server-samples/issues/57
We have a bespoke column based database which we access progamatically using its ADO.NET driver which we wrote in-house. However a colleague wants to use Excel etc to access this database using ODBC.
I expected to find some form of connector to provide an ODBC connection over an ADO.NET datasource (or some config in the ODBC) but I can't find anything.
I know this is using a new tech to connect to a much older one, but its what they want! So if anybody knows of a way to do this it would be much appreciated.
Cheers
John
Sounds like you've created a ADO.NET driver first, as opposed to an ODBC driver first. This sounds a little crazy as everyone knows you can access ODBC driver from ADO/NET but not the other way round.
ODBC is actually a much better interface and used by far more applications, is you question actually correct??
I got an existing database with many tables which are accessed using stored procedures only (no O/RM). I'd like to create new tables in this database using Entity Framework and the Code First approach.
Do all the tables in my existing database need to be modelized in my Entity Framework classes? Will I be able to hand-code only the new classes I need in my DbContext? Other tables really need to stay untouched and away from O/RM for the moment.
Note: I'm going to be using the latest EF5.
As for now the Power Tools only allow you to reverse engineer all tables and views in the DB, which can be a problem if you have a big DB, with hundreds of objects, you do not want to reverse engineer.
However, I found an easy workaround for that:
Create a new technical user for the reverse engineering. To this user you only grant permission to the tables and views, that you want to be reverse engineered.
Have fun!
You are under no obligation to map any given table with EF. If you already have a database, you may want to consider reverse-engineering your database with the EF Power Tools available from Microsoft. I did this recently with a MySQL database that I had for testing purposes and it worked quite well!
If you are new to EF an advantage is that the PowerTools write a ton of code for you, which will help you get a grasp on the syntax of Code First. You will need to modify the output but it is a great start. I really believe that this approach will give you the least headache.
The EF PowerTools can be found here: http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d/
And if that is not possible, what are the implications of using SQL Express? Would there be anything wrong with using SQLExpress for the CMS db, and postgresql for my app?
Orchard does use NHibernate under the bonnet (http://www.orchardproject.net/docs/Orchard-dependencies-and-libraries.ashx), however the orchard web platform installer only allows you to choose between the sql compact database or a SQL Server instance (including express) -
see http://www.orchardproject.net/docs/Installing-Orchard.ashx
So out of the box at the moment no but as Raymond points out you can always write your own provider and contribute it to the Orchard project. (Check out this forum response to mysql - http://orchard.codeplex.com/Thread/View.aspx?ThreadId=229968).
NHibernate is the ORM that Orchard is using to access the database. NHibernate supports postgresql so the answer is yes. And ofcourse you can also write your own dataaccess layer that services access.
A few months after this question was asked, Marek Habersack added Mono support to Orchard. Part of that effort was adding support for running Orchard on PostgreSQL.
The patches for this must have been accepted as the current instructions for running Orchard on Mono do not require them to be added.
There were problems, at least initially, with the connection being dropped but there are reports of it running well.
I am not deeply familiar with this particular product, but unless they explicitly state that they support a certain SQL implementation, the chances are extremely slim that it would just happen to work. A quick look around their site suggests that you will need to use Microsoft's SQL Server.