Npgsql can't find NpgsqlException when doing Migrations

a 夏天 提交于 2019-12-10 09:28:28

问题


When I do an update-database and an error happens at the database I get:

System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Npgsql.NpgsqlException,Npgsql, Version=2.2.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7'.

Its trying to tell me about an error but I presume it can't find the exception type its trying to wrap it in so I'm left guessing at my mistake.

I'm using version 2.2.5.0 Npgsql.EntityFramework which is currently the latest version.


回答1:


This is an open bug on the Npgsql issue tracker:

https://github.com/npgsql/npgsql/issues/714




回答2:


You need to enable Copy Local for Nogsql assembly in the project and optionally also add it to GAC.




回答3:


I came across this issue before. In my case, I had 3 migrations that was created when using SQLServer. When I changed the database to PostgreSql and run update-database, this error showed up.

My Solution was delete all migration scripts, execute Add-Migration, and then the update-database worked just fine.

Hope this will help



来源:https://stackoverflow.com/questions/29852359/npgsql-cant-find-npgsqlexception-when-doing-migrations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!