How to create a custom database using asp.net mvc

I am new to asp.net mvc, so please be as clear as possible.

Here is my goal:

I want to create a simple website where users can:

  • Register and log in
  • Enter your contact information here (phone, address, etc.)
  • View contact information
  • Change details of # 3.

Later on the website I will create other pages that use this data, but at the moment only the elements indicated above are needed.

my questions are that I was looking at the default asp.net mvc sample that appears when you create a new asp.net mvc application.

I am trying to figure out if I should store all the contact information in the aspnetdb.mdf database in an existing table, or should I create new tables.

It seems I can extend aspnet_Users or aspnet_membership.

please let me know if these tables can be expanded to store additional fields or, if it is safer, just create a new table in this database.

+4
source share
3 answers

You can use the Asp.net profile provider to save the information. Follow the instructions for using the built-in SqlProfileProvider. By default, SqlProfileProvider will create tables in the aspnetdb.mdf file, so you can store everything in one place. You can access the profile provider as a property in the HttpContext.

Edit: Best link for ASP.Net profile information

Using the profile provider, you do not need to worry about calling the database or identifying the current user. All this is done on your behalf. Double check the documentation, because the following may be a little off.

You add the fields you want to your web.config, inside <system.web> . In your case, this will be the necessary contact information.

 <profile> <properties> <add name="Address" /> <add name="City" /> <add name="State" /> <plus other fields ... /> </properties> </profile> 

Then you can access HttpContext.Profile.Address, etc., and the provider will take care of binding everything to the current user.

Adding and editing information means displaying the form. Viewing details is simply a display of all the fields saved in the previous form message.

NerdDinner's source and tutorial are well worth checking out if you are completely new to MVC.

+3
source

You can also take a look at the SQL Server Publishing Wizard, which was found here .

It essentially allows you to copy the database structure and / or data to a .sql file, which can then be imported into the main SQL database.

I don't really like the aspnetdb approach, but this is my personal opinion.

0
source

This question was the cause of a small amount of internal debate for me. I see the logic of expanding an existing membership provider to store the necessary additional information, however I would only use the aspnetdb database to store this information, if that was the way to go, since the purpose of this database, in my opinion, is to store the information processed ASP.NET through Membership API

If you decide not to redistribute your existing asp.net membership provider, I would suggest creating another database or at least a few new tables to keep the data that you manage separately from any other ASP-managed data. NET

0
source

All Articles