I’m using Visual Studio 2008, SQL Server 2008, asp.net mvc 2.
Now, I have to change my database to postgresql. I tried many ways. But I did something different.
- I created the data model based on SQL Server 2008 database.
- I have the same structured database in postgresql.
- So I just changed the connection string of the entity data model and I got the following error
The ‘System.Data.SqlClient’ provider from the specified SSDL
artifact(s) does not match the expected ‘Npgsql’ provider from the
connection string.
How do I solve this error.
Please let me know if this is correct way to implement.
Well, the physical layer of your model (the “SSDL” file in your metadata) will of course contain the physical aspects of your database model – including the database provider that this model is based on. You cannot just simply change the database connection string and be done with that…..
I see two options:
my preferred solution: just re-create the EF model based on your Postgres database – that’s the cleanest way to go. If you’re doing it right, this is contained in a single assembly in your project anyway, so you could more or less swap in a new assembly to go against Postgres instead of SQL Server
a hack in my opinion: you could have the metadata files (the *.ssdl, *.msl, *.csdl) for your model written out to disk, and then manually edit the SSDL file to switch to the Postgres provider. I have no idea if that will even work and what side-effects it might have! Do at your own risk, and do it on a backup copy of your project first!