in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

Entity Framework generate model from DB doesn't import cascade settings

Last post 04-17-2010 1:37 PM by Robert Simpson. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-19-2010 8:24 AM

    • jamone
    • Not Ranked
    • Joined on 03-19-2010
    • Posts 1

    Entity Framework generate model from DB doesn't import cascade settings

     I have the following table structure:

    CREATE TABLE [SomeTable] 
    (
       
    [SomeTableID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
       
    [PersonID] INTEGER NOT NULL REFERENCES [Person](PersonID) ON DELETE CASCADE
    )
    CREATE TABLE
    [Person]
    (
       
    [PersonID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT
    )
    When using the model designer in entity framework I choose "Update model from database" and then import those two tables. It reconizes the relationship between the two tables properly but if you check the FK's properties the OnDelete settingsaren't pulled from the DB. They are left on "None". If I then try to delete a Person record that has relating SomeTable records then it crashes saying that you can't null the PersonID in the SomeTable records. If I manually change the OnDelete property of the FK to Cascade just like the DB is set to then everything works as expected.
  • 04-17-2010 1:37 PM In reply to

    Re: Entity Framework generate model from DB doesn't import cascade settings

    That schema information isn't available to me for foreign keys.  I'm not sure I can get it from SQLite.

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems