Skip to content
Loading
  • Nitin Sontakke
    +2
    Which database system is this? You never mentioned. Please specify. Answer changes depending on that.
     
    Whatever system is that does it already have a primary key defined as email address?
     
    Please share as much details as you can, helps us help you better.
    +2
  • Rupesh Kahane
    +2
    How Email id can be a PK.

    As per my info. Their is a Seperate PK per table used (In genearal depends upon requirement & as per architecture suggestion we used PK)
     
    I will suggest add PK with Integer/Decimal datatype into your table & do the changes accordingly.
     
    Note:  It is depends upon the technologies used in project as well.
     
    Let us know which technologies you are used like MVC with EF or any other, which approach you have used to create a database.

    Thanks 
    +2
  • Rupesh Kahane
    +2
    If you want to add PK then first delete old one
    1. alter table Persion drop CONSTRAINT   
    then add new PK. May be your column will get added in last
    1. ALTER TABLE dbo.YourTable  
    2. ADD ID INT IDENTITY  
    3. CONSTRAINT PK_YourTable PRIMARY KEY CLUSTERED  
    Refer my article
    1) http://www.c-sharpcorner.com/article/crud-operation-using-repository-unit-of-work-pattern/

    Other reference
    1) http://www.c-sharpcorner.com/UploadFile/4b0136/database-first-approach-in-mvc-5-part-2/
    +2
  • +1
    Yes sir , you right , i was forget to think about this part . Email_ID have key and therefor  it can not be changed.
     
    I hope its ok  with you if  i ask one more question ,so how can i add one more coulmn for ex Id  , data type int and set that column as Primary key in my existing table !
     
    thx 
    +1
  • +1
    Thx Rupesh , 
    I can use your answer  , when i have Id as primary key , but right i dont have , is just question how can i add primary key in my existing table :)
    +1
  • +1
    @Nitin:
     
    its SQL - Server 
    and 
    in my table , No column's have Primary key and sorry for last comment i mentioned Email_ID have Primary key , but its not.
    and
    in table i have Email_ID data type string and Password data type nvarchar 
    +1
  • +1
    @ Rupesh : 
     
    Im using MVC5 with EF  
    +1
  • +1
    @Rupesh 
    Thx Rupesh i will take look and i will back to you if there is something :) thx for ur help and ur time :) 
    +1