Skip to content

Model First not supported? #424

Closed
Closed

Description

@Swervage

Hello,

many thanks first the work on the DDEX extension.
I've just tried it out. "EF Designer from database" works like a charm.
But when I try creating a database from the model I get the error message:

"[...] No Entity Framework provider found for the ADO.NET provider with invariant name 'Npgsql'. Make sure the provider is registered in the 'entityFramework' section of the application config file [...]"

I suppose this is because this use case is not supported?
The reported error message seems to be misleading as other use case (like described above) do fine.

Regards,
Swervage

Activity

  1. kenjiuno commented on Dec 5, 2014

    @kenjiuno
    Contributor

    Hi @Swervage

    Thanks for trying DDEX extension!

    Ok, are you using EntityFramework 6.0?

    If so, check App.config in your project.

    It has a configuration/entityFramework/providers/provider section?

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    ...
      <entityFramework>
        <providers>
          <!--for EF6.0.x -->
          <!--you need this. add it manually-->
          <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework, Version=2.2.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
        </providers>
      </entityFramework>
    </configuration>
    

    Edit Version=2.2.3.0 to your Npgsql.EntityFramework's assembly version.

    Thanks
    kenji uno

  2. molnargab commented on Jan 19, 2015

    @molnargab

    I seem to get the same exception (on VS 2013 Update 4, Npgsql 2.2.3): model_first_exception

    To reproduce:

    1. Open an .edmx file with the Entity Designer (may need to be created as Model First),
    2. Click 'Generate Database from Model' on the Context Menu.

    It seems the database generation is not aware of the assembly, or VS uses the incorrect template (files in the trace are for T-SQL).

    @Swervage, is it the same you got?
    @kenjiuno, is schema generation supported by Npgsql? I couldn't really find this e.g. on the Wiki.

  3. kenjiuno commented on Jan 20, 2015

    @kenjiuno
    Contributor

    Hi

    Thanks for detail report.

    Click 'Generate Database from Model' on the Context Menu.

    I need to check it in detail. Please let me allow some while to research it.

  4. Emill commented on Jan 20, 2015

    @Emill
    Contributor

    As far as I have understood, "generate database from model" in VS is
    something completely different from migrations. I think we need a .tt
    script that can write postgresql syntax.

    Hi

    Thanks for detail report.

    Click 'Generate Database from Model' on the Context Menu.

    I need to check it in detail. Please let me allow some while to research it.

    —
    Reply to this email directly or view it on GitHub
    #424 (comment).

  5. kenjiuno commented on Jan 20, 2015

    @kenjiuno
    Contributor

    Ok, I knew it (Generate Database from Model) was not available for Npgsql now, sorry.

    As far as I have understood, "generate database from model" in VS is
    something completely different from migrations. I think we need a .tt
    script that can write postgresql syntax.

    Yes. I have checked default "DDL Generation Template" property specified by my edmx. It was SSDLToSQL10.tt.

    I will try to make experimental one (SSDLToPgSQL.tt?) for Npgsql. It will take a while...

    Some sites I have found by googling.

    How to: Customize Database Generation (Generate Database Wizard)

    MySQL seems to have already implemented generator. It will be helpful information to implement new one...

    EF6 and MySQL Generate Database from Model

  6. kenjiuno commented on Jan 26, 2015

    @kenjiuno
    Contributor

    Hi.

    Perhaps it is not easy...

    SSDLToPgSQL.tt (Experimental, not production ready)
    https://gist.github.com/kenjiuno/8f93c1b1bf3c40baabab#file-ssdltopgsql-tt

    1. Copy it to your project.
    2. Make a backup copy of your edmx.
    3. Open your edmx.
    4. Show property of diagram (Right click an empty area, and then choose Property).
    5. Edit [DDL Generation Template] SSDLToSQL10.tt → SSDLToPgSQL.tt
    6. Edit [Database Schema Name] dbo → public (if needed)
    7. Invoke [Generate database from model] (Right click an empty area, and then choose it)
    8. See dialog [Generate Database Wizard], click [Finish]
    9. See dialog [Warning overwriting SSDL/MSL], select [Yes]
    10. See [xxx.edmx.sql] in a new text editor (T-SQL highlighting enabled)
    11. Copy the entire text into clipboard.
    12. Launch pgAdmin or such.
    13. Run the SQL queries at that tool.

    Screen shots:

    4. Show property of diagram (Right click an empty area, and then choose Property).

    edmxprop

    8. See dialog [Generate Database Wizard], click [Finish]

    dbgenwiz

    10. See [xxx.edmx.sql] in a new text editor (T-SQL highlighting enabled)

    tsqleditor

  7. kenjiuno commented on Jan 26, 2015

    @kenjiuno
    Contributor

    Here is an entire output from my sample wflow db:

    -- Created: 2015/01/26 14:54:32
    -- Tables
    CREATE TABLE "dbo"."wflow_footer" (
        "file" INT8 NOT NULL,
        "doc" INT8 NOT NULL,
        "seq" INT8 NOT NULL,
        "person" TEXT,
    CONSTRAINT "PK_wflow_footer" PRIMARY KEY ("file", "doc", "seq")
    );
    CREATE TABLE "dbo"."wflow_header" (
        "file" INT8 NOT NULL,
        "title" TEXT,
    CONSTRAINT "PK_wflow_header" PRIMARY KEY ("file")
    );
    CREATE TABLE "dbo"."wflow_attach" (
        "file" INT8 NOT NULL,
        "doc" INT8 NOT NULL,
        "seq" INT8 NOT NULL,
        "attach" INT8 NOT NULL,
        "path" TEXT,
    CONSTRAINT "PK_wflow_attach" PRIMARY KEY ("file", "doc", "seq", "attach")
    );
    CREATE TABLE "dbo"."wflow_footer_extra" (
        "file" INT8 NOT NULL,
        "doc" INT8 NOT NULL,
        "seq" INT8 NOT NULL,
        "action" TEXT,
        "expire" TIMESTAMPTZ,
    CONSTRAINT "PK_wflow_footer_extra" PRIMARY KEY ("file", "doc", "seq")
    );
    -- Foreign Key Constraints
    ALTER TABLE "dbo"."wflow_footer" ADD CONSTRAINT "FK_wflow_footer_file_fkey" FOREIGN KEY ("file")
    REFERENCES "dbo"."wflow_header"("file")
    ON DELETE NO ACTION
    ;
    
    ALTER TABLE "dbo"."wflow_attach" ADD CONSTRAINT "FK_wflow_attach_file_fkey" FOREIGN KEY ("file", "doc", "seq")
    REFERENCES "dbo"."wflow_footer"("file", "doc", "seq")
    ON DELETE NO ACTION
    ;
    
    ALTER TABLE "dbo"."wflow_footer_extra" ADD CONSTRAINT "FK_wflow_footer_extra_file_fkey" FOREIGN KEY ("file", "doc", "seq")
    REFERENCES "dbo"."wflow_footer"("file", "doc", "seq")
    ON DELETE NO ACTION
    ;
    
    -- EOF

    wflow

  8. kenjiuno commented on Apr 27, 2015

    @kenjiuno
    Contributor

    todo

    • Include SSDLToPgSQL.tt in the setup, and put into C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen folder. It will be listed in [DDL Generation Template].
    • Write to wiki about Model first support.
  9. self-assigned this
    on Apr 27, 2015
  10. Emill commented on Aug 23, 2015

    @Emill
    Contributor

    Hi @kenjiuno. What is the status for this?

  11. kenjiuno commented on Aug 24, 2015

    @kenjiuno
    Contributor

    This is not yet done. It should be done with #718

  12. funny-falcon commented on Mar 30, 2017

    @funny-falcon
    Contributor

    Is it fixed now?

  13. roji commented on Apr 2, 2017

    @roji
    Member

    @funny-falcon, the DDEX extension was rewritten for 3.2 - but I'm not sure whether this works or not. @kenjiuno, any chance you could look?

  14. kenjiuno commented on Apr 3, 2017

    @kenjiuno
    Contributor

    @roji
    C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen folder is write protected. So VSIX setup won't write there. We need an Administrator privileges to accomplish this installation.

    Some ways to do this: add an instruction steps for manual installation under http://www.npgsql.org/doc/ddex or
    I can prepare a small and separated setup only for SSDLToPgSQL.tt.
    Setup is simple. Copy SSDLToPgSQL.tt to necessary locations.

    image

  15. Pierre-Henry-Dufetel commented on May 10, 2018

    @Pierre-Henry-Dufetel

    capture

    I get the EF5 error again , I managed to get past this in order to Update Model From DB by adding EF5 dll in PrivateAssemblies but appears again ussing this script

  16. roji commented on Jun 8, 2018

    @roji
    Member

    Closing for age for mixing too many issues. Specific new issues can be opened again after testing on recent versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions