Type is not resolved error when using database migration

2,890 views
Skip to first unread message

remolu...@gmail.com

unread,
Dec 11, 2014, 3:07:49 AM12/11/14
to npgsq...@googlegroups.com
Hi all,

I'm using the latest NuGet Version of Npgsql (2.2.3) and created a test project for evaluating npgsqsl and Entity Framework 6.
Everything works fine, I can access the database via EF but I can't get EF's database migrations to work. I'm not sure if this is a bug, maybe I'm doing something wrong...

Here is what I did this far:
- Enable-Migrations...OK
- Add-Migrations v1...OK
- Update-Database...FAILED with this error message:

PM> Update-Database

Specify the '-Verbose' flag to view the SQL statements being applied to the target database.

Applying explicit migrations: [201412101611313_v1].

Applying explicit migration: 201412101611313_v1.

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

at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)

at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)

at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)

at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()

at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)

Type is not resolved for member 'Npgsql.NpgsqlException,Npgsql, Version=2.2.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7'.


Does anybody see the same error?



Here is my app.config. Maybe there is missing something?

<?xml version="1.0" encoding="utf-8"?>

<configuration>

<configSections>

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>

<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->

</configSections>

<system.data>

<DbProviderFactories>

<!--for EF4.x and EF6.0.x -->

<!--you may need this. if you don't modify machine.config-->

<remove invariant="Npgsql"/>

<add name="Npgsql - .Net Data Provider for PostgreSQL" invariant="Npgsql"

description=".Net Data Provider for PostgreSQL" support="FF"

type="Npgsql.NpgsqlFactory, Npgsql"/>

</DbProviderFactories>

</system.data>

<connectionStrings>

<!--for EF4.x and EF6.0.x -->

<add name="DefaultConnection" connectionString="Server=127.0.0.1;port=5432;Database=Test;User Id=markus;Password=beetle;" providerName="Npgsql"/>

</connectionStrings>

<startup>

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

</startup>

<entityFramework>

<!--<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">

<parameters>

<parameter value="mssqllocaldb"/>

</parameters>

</defaultConnectionFactory>-->

<providers>

<!--<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />-->

<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework"/>

</providers>

</entityFramework>

</configuration>


Pete Kane

unread,
Dec 12, 2014, 2:08:57 AM12/12/14
to npgsq...@googlegroups.com
I don't think migrations are supported.

remolu...@gmail.com

unread,
Dec 15, 2014, 5:49:51 AM12/15/14
to npgsq...@googlegroups.com
Since 2.2.0 migrations are supported:


Entity Framework

David Karlaš added support for EFMigration and Database creation in EF6+. 
Now it is possible to start Code First projects without needing to create a database upfront. EntityFramework and Npgsql will take care of it.
Emil Lenngren added support for a lot of missing features of EntityFramework.

Francisco Figueiredo Jr.

unread,
Dec 15, 2014, 6:08:31 AM12/15/14
to npgsq...@googlegroups.com

This is very strange. It seems the process isn't being able to see the type in the Npgsql.dll assembly.

Is Npgsql.dll installed into GAC, or is it only in your project bin folder?

I found something about this type of error in this stackoverflow question: http://stackoverflow.com/questions/13729089/serializationexception-type-is-not-resolved-for-member
Maybe we are also missing the MarshalByRefObject extension in the NpgsqlException. If this is the case, your usage may be somehow different from the usual way David Karlas used when programming this feature.

Are you able to recompile Npgsql from source? If so, would you mind to try adding the MarshalByRefObject extension to the NpgsqlException class and check if it makes it work?

Thanks in advance.

michae...@gmail.com

unread,
Jan 14, 2015, 3:16:14 PM1/14/15
to npgsq...@googlegroups.com
I received this exact error on the initial create script when I could not access the target database. Have you double checked to make sure you haven't since lost connectivity to the database?

Regards,
Michael
Reply all
Reply to author
Forward
0 new messages