Goal:
I want to be able to identify customers,
their invoices. etc--
using an IDENTITY FIELD that I create
(rather than the UserID or the UserName
that are the ASP.NET defaults.)
How can I add an identity field to the
aspnet_Users default membership table?
(The identity field will automatically
increment by one--every time a new
user gets added.)
(Each "user" is a customer.)
Is having this identity field
better than using the default
UserID or UserName---
(in aspnet_Users)
or should I use
UserID or UserName
to identify users ( = customers)
their invoices, etc.
----
Details:
I am using the default database ASPNETDB.MDF that
gets automatically created when you create a new
ASP.NET application and go into the
ASP.NET Web Site Administration Tool.
ASPNETDB.MDF comes with several membership tables like:
aspnet_Users
aspnet_Membership
etc.
I want to start ADDING TABLES to this database---
to create my own custom application.
For example, simple add a CUSTOMERS table,
and a simple INVOICES TABLE to
ASPNETDB.MDF
I am new to ASP.NET / SQL SERVER.
Is this the correct thing to do?
(Rather than creating a separate database of
customers, invoices, etc. and trying to link
the two databases in some way.)
I would like to have some kind of "USER ID"
for the CUSTOMER so I can use it in the INVOICES
table to identity which invoices come from which customer.
There appear to be 3 options for what to use
as my "USER ID".
Option #1:
Use the
UserID (the GUID)
that automatically
comes with the ASP.NET membership tables.
Option #2
Use the
UserName nvarchar(256)
that automatically
comes with the ASP.NET membership tables.
Option #3
Create some kind of identity field
that is an integer an increases by one
every time a new user (= customer) is added.
I would like to use option #3.
Is this a good or bad thing to do??
I have tried to add this identity field
several times.
However, every time I add a field
UserIDCounter
to the table
aspnet_Users
(and make it an identity field that
increments by one)
SQL SERVER seems to modify
several related tables---
and then corrupts the database!
It appears that by me adding that identity field,
I am messing up the existing relationships in some way
(even though I did NOT make this the PRIMARY KEY.)
Is it possible to add an identity field
UserIDCounter
to
aspnet_Users
and have
UserIDCounter
automatically
increment by one every time
a new user (= customer) gets added?
This will give me a
unique field--
that I can then index
and use as my
own
"USER ID" to
identify a customer and their invoices.
How do I do this--without corrupting the database??
Is this a good way to identify customers,
their invoices, etc--or should I use Option 1
or Option 2---and if so--which is better--
and why?
Note:
I assume I have to leave the existing UserID
(GUID) as my primary key--since the default
ASP.NET membership system is already
set up that way.
However, I assume that if I can accomplish Option 3
above--I will have my own way to identify customers,
invoices, etc--
while allowing the existing default
membership system to run correctly--
as it was originally set up.
Is this possible--to add my identity field--
while allowing the ASP.NET
membership system to run the way it way
designed to run?
Thanks a lot for your help!
HELPLIFE888