How to create a database and fill it during installation

I would like to find a way to create and populate the database during the installation of asp.net.

So, I am ready to do this:

  • Create a database during setup
  • Fill the database with some raw data (country codes or something like that)
  • Create the appropriate connection string in the configuration file

I am using .NET 3.5 and Visual Studio 2005 , and the database is SQL Server 2005.

Thanks in advance.

+3
source share
4 answers

, MSDN: .

, , , , , .

+1

, , , .

.

  • application_start Global.asax, , , .
  • .
  • web.config

, . , .

+3

, SQL-. , , .

, script. , , :

. CREATE DATABASE, CREATE SCHEMA, CREATE TABLE, CREATE VIEW .., INSERT .

, YMMV:

  • script
  • " " ( aspnet_regsql -, Enterprise Library procs)
  • script, ( )
  • script

, script .

(IF EXISTS ..). , , .

!

+2

Linq Sql, .
Linq to Sql. , , System.Data.Linq.DataContext, .

DataContext.CreateDatabase() .

. .

+1

Source: https://habr.com/ru/post/1704286/


All Articles