How to use my already populated Firebird database for a web project in visual Studio 2015 using Entity framework?

Asked

Viewed 601 times

1

I have an already populated Firebird database and would like to use this same database for a Web project in visual studio 2015.

I already installed Firebird ADO.NET Data Provider and tried to give a "conect to database" in visual studio, selected "Firebird Data Source", dei continue but when I select DB in the "add conecction" window the window closes and I have to restart the process in "conect to database".

How can I make this connection from my Firebird DB to VS ?

Thank you.

2 answers

1

This is the old way of working with the Entity Framework. The most current way uses only project file settings web.config and Nuget packages.

The ADO.NET provider to Firebird and its respective Entity Framework support can be easily installed using the following commands in the Package Manager Console (View > Other Windows > Package Manager Console):

PM> Install-Package FirebirdSql.Data.FirebirdClient
PM> Install-Package EntityFramework.Firebird

The setting in the web.config is done as follows:

  <configuration>
    ...
    <entityFramework>
        <defaultConnectionFactory type="FirebirdSql.Data.EntityFramework6.FbConnectionFactory, EntityFramework.Firebird" />
        <providers>
            <provider invariantName="FirebirdSql.Data.FirebirdClient" type="FirebirdSql.Data.EntityFramework6.FbProviderServices, EntityFramework.Firebird" />
        </providers>
    </entityFramework>
    ...
  </configuration>

In addition, it is necessary to inform a Connection string in the same file:

<configuration>
  ...
  <connectionStrings>
    <add name="DefaultConnection" connectionString="User=usuario;Password=senha;Database=C:/caminho/do/arquivo.fdb;DataSource=localhost;Port=3050;Dialect=3;Charset=NONE;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet size=8192;ServerType=0;" providerName="FirebirdSql.Data.FirebirdClient" />
  </connectionStrings>
  ...
</configuration>

EDIT

For reverse engineering, install the DDEX software in your Visual Studio. You can download it here.

  • I installed the packages already but intended to use a library class for the model. How do this configuration in the library class ?

  • 1

    Ask another question, please. It’s gonna be kind of out of context for me to put it all here.

  • Do I use App.config? I would like to do the other way to generate domain classes through DB using reverse engineering in the Entity Framework. Is it possible to do that ? Thank you.

  • @Victorglauber I updated the answer.

  • @Ciganomorrisonmendes I already have DDEX installed, VS recognizes the Firebird Data Source (.NET Framework Data Provider for Firebird) as possibility to add a new connection VS - DB but the VS or cancels the operation of add conection and back on the home screen or hangs and reboots. Is there any other way to reverse engineer this case? Thank you

  • I’m installing the providers here to reproduce the problem. Apparently it’s something in your configuration.

Show 2 more comments

0

I was able to make the connection only the old way, creating a Connection String and accessing the DB by SQL calls. This will make it difficult for me to develop, because I will not be able to use code first the way I would like.

If anyone else needs help in this same problem follow the link that helped me. HERE!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.