I'm trying to set up Firebird with EF6 as an embedded server for a simple app I'm writing but haven't been able to get it to work. I have a CLI project which is the app and the DAL project which is the DB. I added the NuGet packages to both and created a DbContext with a simple entity, and created an initial migration successfully, but when trying to run
update-database to execute the migration I received this error in the Package Manager Console:
System.Runtime.Serialization.SerializationException: Type is not resolved for member 'FirebirdSql.Data.FirebirdClient.FbException,FirebirdSql.Data.FirebirdClient, Version=184.108.40.206, Culture=neutral, PublicKeyToken=3750abcc3150b00c'. 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 'FirebirdSql.Data.FirebirdClient.FbException,FirebirdSql.Data.FirebirdClient, Version=220.127.116.11, Culture=neutral, PublicKeyToken=3750abcc3150b00c'.
Actually I just noticed that nothing works now... If I remove my migration and try to recreate it, I get this error. I was able to enable migrations and create one before, but now I can't. Bizarre.
All of my projects are targeting .NET 4.5.2 and they all have the same package versions. My solution/project path has no spaces or ampersands or weird characters in it. I've tried using my app project as the startup project and the DAL project and that didn't make a difference.
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="EntityFramework" version="6.1.3" targetFramework="net452" /> <package id="EntityFramework.Firebird" version="18.104.22.168" targetFramework="net452" /> <package id="FirebirdSql.Data.FirebirdClient" version="22.214.171.124" targetFramework="net452" /> </packages>
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> </configSections> <connectionStrings> <add name="DAL.DbContext" providerName="FirebirdSql.Data.FirebirdClient" connectionString="User=SYSDBA;Password=masterkey;Database=SampleDatabase.fdb;DataSource=localhost;Port=3050;Dialect=3;Charset=NONE;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=1;" /> </connectionStrings> <entityFramework> <defaultConnectionFactory type="FirebirdSql.Data.EntityFramework6.FbConnectionFactory, EntityFramework.Firebird" /> <providers> <!--<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />--> <provider invariantName="FirebirdSql.Data.FirebirdClient" type="FirebirdSql.Data.EntityFramework6.FbProviderServices, EntityFramework.Firebird" /> </providers> </entityFramework> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-188.8.131.52" newVersion="184.108.40.206" /> </dependentAssembly> </assemblyBinding> </runtime> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> <system.data> <DbProviderFactories> <remove invariant="FirebirdSql.Data.FirebirdClient" /> <add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient" /> </DbProviderFactories> </system.data> </configuration>
The connection string I just found on the net so that might be wrong, but I couldn't find any documentation for it...
I've done code-first EF dozens of times with SqlServer before and never ran into this problem before, but this app won't have a real server to hit. Unfortunately this seems like a more general problem than Firebird or EF, but I'm not sure where to even look at this point.
I had this same exact issue and was able to figure out exactly what was going on with the help of the previous answer. It is a known bug and they have a fix for 6.2. The exception is hiding a deeper problem that may be difficult to know without a proper stack trace. A workaround is to upgrade your Entity Framework to the latest 6.2 pre-release build and see what the real problem is then revert back to your current build, in my case it was 6.1.3
At this point you should see a detailed error message of what is wrong and it should give you a better idea of what you need to do to resolve the issue. In my case there was an issue with accessing a file and Visual Studio needed to be ran as an Administrator.
Once you resolve the issue you can either undo your changes to entity framework version or follow the steps above but updating your version to the previous version you were using.