in

System.Data.SQLite

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

Entity Framework - edmx file - primary key - autoincrement (StoreGeneratedPattern="Identity")

Last post 09-15-2010 3:21 PM by rdmartin. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 01-09-2010 4:36 PM

    • magik
    • Top 500 Contributor
    • Joined on 01-09-2010
    • Posts 5

    Entity Framework - edmx file - primary key - autoincrement (StoreGeneratedPattern="Identity")

     I'm using VB.Net in Visual Studio 2008

    and SQLite Expert 2.3.19.1936 to generate the database and create the table

    and version 1.0.65.0 of System.Data.SQLite

    Here's my table creation:

    CREATE TABLE app_param
    (
           param_id INTEGER,
           param TEXT NOT NULL,
           info TEXT NOT NULL,
           PRIMARY KEY(param_id ASC)
    )

     I created a new Entity Data Model using it and it doesn't seem to generate the StoreGeneratedPattern="Identity" in the created .edmx file which causes some problem when using the database.

    It could be added manually, but it would be easier if it would be by default.

     

    Here's a sample of the generated edmx file's xml (from the EDMX:StorageModels section):

    <EntityType Name="app_param">
     <Key>
      <PropertyRef Name="param_id" />
     </Key>
     <Property Name="param_id" Type="integer" Nullable="false" />
     <Property Name="param" Type="nvarchar" Nullable="false" />
     <Property Name="info" Type="nvarchar" Nullable="false" />
    </EntityType>

     

    Here's my addition to it:

    <EntityType Name="app_param">
     <Key>
      <PropertyRef Name="param_id" />
     </Key>
     <Property Name="param_id" Type="integer" Nullable="false" StoreGeneratedPattern="Identity" />
     <Property Name="param" Type="nvarchar" Nullable="false" />
     <Property Name="info" Type="nvarchar" Nullable="false" />
    </EntityType>

    * I'm not entirely sure if it isn't a current limitation of the Entity Framework or related to the provider.

     

    By the way thanks a lot for this provider I'm using it for some personal projects and it works really well. :)

  • 09-15-2010 3:21 PM In reply to

    Re: Entity Framework - edmx file - primary key - autoincrement (StoreGeneratedPattern="Identity")

     Thanks so much for posting this! I've been banging my head for a while. The fix is to edit the edmx file as suggested.

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