I am stuck in the middle of a project. I am having an issue with adding the data source in "Entity Data Model Wizard"
Navigation Path:::::
Solution Explorer : Models(Folder): Add : New Item : ADO.NET Entity Data Model : EF Designer From Database : New Connection
Now here in "New Connection" I want to connect my postgresql database using Postgresql Datasource but I have only SQL Server datasource option there, Anybody know how to deal with this ERROR..??
Note: I have added Npgsql, entityframework5.Npgsql through NuGet.
Related
I am using .net core entity framework.
I have multi tenant dbs. so I have kept one root tenant db as base. and I want to replicate those schema changes to all other dbs using entity framework. I am generating my models using following command.
Scaffold-DbContext "Data Source=(local);Initial Catalog=sampleTenantDb;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Tenants -Force
So when creating new tenant, I simply use
context.Database.EnsureCreated();
But when I add new table in code, I want to apply it to all tenants. So how do I do it?
I tried following but, it doesn't work (not adding remanining tables)
myDbContext.Database.Migrate();
If your DbContext is created with Scaffold-DbContext, it won't have any Migrations. That's for a database-first workflow, in which you would apply the DDL changes to the tenant databases with a script, perhaps created with SQL Server Data Tools.
You have need to create multiple dbcontext object and and pass connection string in that way you can update multiple db
I'm creating an ASP MVC 3 website. I have a Postgresql database - I'm using Entity Framework 6 - I have referenced Npgsql and Npgsql.EntityFramework and installed dotConnect for PostgreSQL. The connection with the Postgresql database works fine - when I want to add a database connection I have PostgreSQL server in the data source list:
But when I want to add an ADO.NET Entity Data Model to the project there isn't PostgreSQL server in the data source list :
I have an application which can connect to OLE DB data sources, however, my proprietary database has only ADO.NET provider.
Is there any ADO.NET to OLE DB bridge which could helps me to connect to ADO.NET data source?
EDIT:
I do not have control on application. It is some kind of reporting service. Here is how I expect to connect:
App <-> OLE DB Provider <-> (bridge?) <-> ADO.NET Data Source
Everything is running on Windows machine
You didn't mention the platform so I am going to assume things and point you to some direction.
For the .NET Framework Data Provider for OLE DB, the connection string
format is identical to the connection string format used in ADO
For more details you can refer to this page to get started:
Connecting to an OLE DB Data Source Using ADO.NET
And also it wouldn't hurt to have a look at this title Connecting to an OLE DB Data Source
in the following MSDN article (.NET 4.5)
Establishing the Connection
Update
On the other hand to access a ADO.NET data source using an OLE DB you can follow this example.
However if you mean by the word "bridge" to have something like
using (SqlConnection connection = new SqlConnection(oleConnectionString))
where, oleConnectionString is an originally an OLE connection string which is converted to act as an SQL connection string?! I am not sure if that's possible.
ADO.NET Sample
I created an SQL Express database and built an Entity Data Model off of it using the wizard, then used the Repository Pattern to generate a helper class that does my querying for me.
Unfortunately what I didn't realize is that Code First creates a localdb copy and basically ALL my add/removes now go to this ethereal location that I can't find so I can't run queries off the data in SQL Express. Now I know the data is being saved because I'm able to check the underlying model through breakpoints and queries during page load with using(Context = new Context()) { /query stuff/ }, but I don't know how to switch from the underlying model back to my SqlExpress instance.
Any thoughts?
LocalDb is just another sql server database, which is started by Visual Studio. It's data most of the time are in %USER% directory and you can open it with Sql Server Management Studio. To switch your project to your sql express instance, you need to change the connection string, that's all.
Similar to this question, I am trying to run an Entity CodeFirst project. I'm using the CreateDatabaseIfNotExists initializer. I am a sysadmin on the box the connect string points to.
If I change (or remove) the connection string, Entity will create the database on my local SQLExpress instance. Why won't it create the database on my remote instance? And, furthermore, why does it seem to require an artifact of data-first? This is a brand new project that is using nothing but code-first.
Using EF4.2. Remote machine is SQL2k8.