Using Massive; in a WPF Application with EF - c#

I want to use Massive ORM(by Rob Conerys) in a WPF Application using Entity Framework.
It sais to add in app.config the providerName = 'System.Data.SqlClient'
but using EF I have System.Data.EntityClient and I get this error : "Unable to find the requested .Net Framework Data Provider. It may not be installed."
Any suggestions ?

You can solve this by creating a second connection string specifically for Massive.

Related

ASP.NET MVC C# change code from accessing a mySQL database to a MSSQL database

I have an application that I used to connect to a mySQL database. I have installed the MySQL.Data package and I use this code to build my connection:
services.AddScoped<System.Data.IDbConnection>((s) =>
{
IDbConnection conn = new MySqlConnection(Configuration.GetConnectionString("databasename"));
conn.Open();
return conn;
});
This works fine as I am able to read/write data from the database.
Now, I need to have the same application access a MS SQL database. The tables are all the same and the fields on each table are the same as well. I am having a hard time finding what I should change my code to (or what package I should include). When I remove the MySQL.Data package, the MySqlConnection function becomes invalid (as would be expected).
Any idea what package to include and what function to use to establish the connection?
Any assistance is greatly appreciated.
Thank you!
EDIT #1
I found an old stackoverflow post (I should have referenced it here but I closed the window) that talks about this very issue. The suggestion was to add
using System.Data.SqlClient;
and then change the assignment code to
IDbConnection conn = new SqlConnection(Configuration.GetConnectionString("databasename"));
I made these changes and now I get this error within the code:
Im at a loss as to how to resolve this. I verified that my project is in framework .NET core 3.1
Not sure about size of your project and detailed requirements but I would suggest to use libraries like:
Entity Framework - no SQL knowledge needed, can connect to any Db technology, almost no code changes required when switching between Db providers
or
Dapper - fast lightweight also supports multiple Db providers but you need to write correct SQL commands yourself specific for each Db technology you use

Entity Framework with IBM DB2

We have a DB2 database which we are accessing via EF. We are able to connect to the database and do read & write operations as part of this.
Now the plan is to initialize the DB using
Database.SetInitializer(new CreateDatabaseIfNotExists<CustomContext>())
This throws out an error saying
HResult=-2146232032
Message=CreateDatabase is not supported by the provider.
Source=EntityFramework InnerException:
System.Data.Entity.Core.ProviderIncompatibleException
Previously we were connecting with
Database.SetInitializer(new NullDatabaseInitializer<CustomContext>());
and this was working fine.
The question is has any one tried creating a new DB2 database from within EF?
You cannot do that.That is Known limitation of the provider.
General limitations:
Only database-first scenarios are supported: any database object that
you reference in Entity Framework must first exist in the database.
Invocation of store-specific functions is not supported.
Trusted context connection properties that you set in the Server Explorer Add
Connection dialog are not passed to Entity Framework connections.
You can read it here : Limitations to Microsoft Entity Framework support
Migration is not supported by IBM EF provider implementation.
If you need DB2 migration support you can use this package that implements only migration (so you can use it in addition to IBM DB2 EF Provider)
https://www.nuget.org/packages/System.Data.DB2.EntityFramework.Migrations/
You can find more info here
https://db2ef6migrations.codeplex.com/

Manipulating RSSBus for Quickbooks ADO.net ConnectionString

I've written an app using the RSSBus QB ADO.net provider - VS 2010 and .net 4.0. I'm connecting to QB with the entityframework 6 and using linq.
I'm dynamically changing the connectionstring in order to manipulate the offline cache. Everything works great.
I've migrated the app to VS 2013 with .net 4.5. In vs2010/4.0 the QB entity object is of ObjectContext and in vs2013/4.5 the QB entity is of DbContext and I don't have the connectionstring property available.
Is there any other methodology to manipulate the cache settings on the connection?
DbContext does not directly have a Connection property but it does have Database which does contain a Connection object which should allow you to edit the connection string:
https://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext%28v=vs.113%29.aspx
There's another method you can use involving a partial class shown here:
EF 5 Changing Connection String at Runtime

the requested database is not defined in configuration while calling CreateDatabase method

I'm trying to use Enterprise Library to create database connection and it gives the error "the requested database is not defined in configuration"
I have 2 config files. One is for appSettings and the other is for connection string. We use a custom framework to take the config values from an external path in the system, eg.
C:\application\environments\dev\environments.config
C:\application\environments\dev\connections.config
The environment.config has a connectionString element which has the configSource="connections.config".
When I run the application, I'm able to get all the appSetting from the environments.config, but when I try to call the DatabaseFactory.CreateDatabase("dbConnection"), it throws the error. I'm not sure if I'm missing something or not. I read through many articles and couldn't find the exact problem.
I use Enterprise Library Common and Data dll and their version is 3.1.1.0. My .NET framework is 4.0.
Can anybody please provide me some idea to make this work?
Do I need to make any setting changes in machine.config?

Using Npgsql provider with OLE database connection

So I have the following connection string which is causing me issues. I am attempting to write an application which is capable of being database agnostic (difficult but not impossible) and I have come to testing it on PostgreSQL however I cannot seem to get an OLE connection to work with it. From what I have seen it is entirely possible.
I got everything working using a specific class for PostgreSQL but this used the Npgsql types rather than generic OLE types.
E.g.
private NpgsqlCommand m_postgreSQLDatabaseCommand;
Instead of
private OleDbCommand m_oleDatabaseCommand;
This is not acceptable in my circumstances.
I tried simply changing the connection string to use the Npgsql provider but I am not sure if I am using it correctly. I get the error below:
Connection String:
<add name="ApplicationPostgresDefault"
connectionString="Server=127.0.0.1;Port=5432;
Database=myDatabase;
User Id=myUser;
Password=myPass;
Provider=Npgsql"
/>
Error:
The 'Npgsql' provider is not registered on the local machine.
What can be done to solve this?
If I get the provider in there correctly will I be able to communicate with PostgreSQL as I was with Npgsql objects?
The local machine doesn't have the provider installed.
I would suggest using a native client rather than OleDb anyway:
http://npgsql.projects.postgresql.org/
http://connectionstrings.com/Providers/npgsql
that's your choose
Are you missing a ; after Npgsql ?

Categories

Resources