(This question follows an excellent post on using Npgsql).
I have a PostgreSQL (9.5.0) database with two schemas: public and nova. I then used NuGet console:
Install-Package EntityFramework6.Npgsql -Version 3.0.5
Now I add the following element to the app.config file:
<system.data>
<DbProviderFactories>
<remove invariant="Npgsql"/>
<add name="Npgsql Data Provider"
invariant="Npgsql"
description=".Net Data Provider for PostgreSQL"
type="Npgsql.NpgsqlFactory, Npgsql, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"
support="FF" />
</DbProviderFactories>
</system.data>
Then I added a new "ADO.NET Entity Data Model" to my project.
The following connection properties were filled in:
Database: chaos
Host: localhost
Password: psw
Port: 5432
Search Path: nova
Username: postgres
The connection is then tested and everything works.
The Entity Framework is then built with database first. The .edmx file is built correctly and the VS designer is happy.
The problem is the .edmx file is built from all the tables in the database. That is, both the public and nova schema's tables are in the .edmx file.
In addition to specifying the search path in the connection properties, I have tried the following on the database--but these do not change both schemas being added to the .edmx file:
- ALTER DATABASE chaos SET search_path TO nova;
- ALTER USER postgres SET search_path to nova;
- ALTER SCHEMA public RENAME TO public_old;
Is there any way to build the Entity Framework with only the one schema, Nova?
My components:
- Windows 10 Professional
- Entity Framework 6.0.0
- Npgsql 3.0.5
- PostgreSQL 9.5.0
- Visual Studio 2015
TIA
.edmxmodel file - can't you just select the objects from theNovaschema and leave out the others? (That's the way it would work in SQL Server - I don't know PostgreSQL so I can't say how it works there)