text: ﻿CREATE TABLE [AspNetRoles] (
      [Id] nvarchar(450) NOT NULL,
      [Name] nvarchar(256) NULL,
      [NormalizedName] nvarchar(256) NULL,
      [ConcurrencyStamp] nvarchar(max) NULL,
      CONSTRAINT [PK_AspNetRoles] PRIMARY KEY ([Id])
  );
  GO
  
  
  CREATE TABLE [AspNetUsers] (
      [Id] nvarchar(450) NOT NULL,
      [UserName] nvarchar(256) NULL,
      [NormalizedUserName] nvarchar(256) NULL,
      [Email] nvarchar(256) NULL,
      [NormalizedEmail] nvarchar(256) NULL,
      [EmailConfirmed] bit NOT NULL,
      [PasswordHash] nvarchar(max) NULL,
      [SecurityStamp] nvarchar(max) NULL,
      [ConcurrencyStamp] nvarchar(max) NULL,
      [PhoneNumber] nvarchar(max) NULL,
      [PhoneNumberConfirmed] bit NOT NULL,
      [TwoFactorEnabled] bit NOT NULL,
      [LockoutEnd] datetimeoffset NULL,
      [LockoutEnabled] bit NOT NULL,
      [AccessFailedCount] int NOT NULL,
      CONSTRAINT [PK_AspNetUsers] PRIMARY KEY ([Id])
  );
  GO
  
  
  CREATE TABLE [Deportes] (
      [Id] int NOT NULL IDENTITY,
      [Nombre] nvarchar(50) NOT NULL,
      CONSTRAINT [PK_Deportes] PRIMARY KEY ([Id])
  );
  GO
  
  
  CREATE TABLE [Socios] (
      [Id] int NOT NULL IDENTITY,
      [Nombre] nvarchar(50) NOT NULL,
      [Apellido] nvarchar(50) NULL,
      [Telefono] int NOT NULL,
      [Mail] nvarchar(max) NOT NULL,
      [Baja] bit NOT NULL,
      CONSTRAINT [PK_Socios] PRIMARY KEY ([Id])
  );
  GO
  
  
  CREATE TABLE [AspNetRoleClaims] (
      [Id] int NOT NULL IDENTITY,
      [RoleId] nvarchar(450) NOT NULL,
      [ClaimType] nvarchar(max) NULL,
      [ClaimValue] nvarchar(max) NULL,
      CONSTRAINT [PK_AspNetRoleClaims] PRIMARY KEY ([Id]),
      CONSTRAINT [FK_AspNetRoleClaims_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE CASCADE
  );
  GO
  
  
  CREATE TABLE [AspNetUserClaims] (
      [Id] int NOT NULL IDENTITY,
      [UserId] nvarchar(450) NOT NULL,
      [ClaimType] nvarchar(max) NULL,
      [ClaimValue] nvarchar(max) NULL,
      CONSTRAINT [PK_AspNetUserClaims] PRIMARY KEY ([Id]),
      CONSTRAINT [FK_AspNetUserClaims_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
  );
  GO
  
  
  CREATE TABLE [AspNetUserLogins] (
      [LoginProvider] nvarchar(450) NOT NULL,
      [ProviderKey] nvarchar(450) NOT NULL,
      [ProviderDisplayName] nvarchar(max) NULL,
      [UserId] nvarchar(450) NOT NULL,
      CONSTRAINT [PK_AspNetUserLogins] PRIMARY KEY ([LoginProvider], [ProviderKey]),
      CONSTRAINT [FK_AspNetUserLogins_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
  );
  GO
  
  
  CREATE TABLE [AspNetUserRoles] (
      [UserId] nvarchar(450) NOT NULL,
      [RoleId] nvarchar(450) NOT NULL,
      CONSTRAINT [PK_AspNetUserRoles] PRIMARY KEY ([UserId], [RoleId]),
      CONSTRAINT [FK_AspNetUserRoles_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE CASCADE,
      CONSTRAINT [FK_AspNetUserRoles_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
  );
  GO
  
  
  CREATE TABLE [AspNetUserTokens] (
      [UserId] nvarchar(450) NOT NULL,
      [LoginProvider] nvarchar(450) NOT NULL,
      [Name] nvarchar(450) NOT NULL,
      [Value] nvarchar(max) NULL,
      CONSTRAINT [PK_AspNetUserTokens] PRIMARY KEY ([UserId], [LoginProvider], [Name]),
      CONSTRAINT [FK_AspNetUserTokens_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
  );
  GO
  
  
  CREATE TABLE [Pistas] (
      [Id] int NOT NULL IDENTITY,
      [Numero] nvarchar(max) NOT NULL,
      [Descripcion] nvarchar(50) NOT NULL,
      [Localizacion] nvarchar(max) NOT NULL,
      [DeporteId] int NOT NULL,
      CONSTRAINT [PK_Pistas] PRIMARY KEY ([Id]),
      CONSTRAINT [FK_Pistas_Deportes_DeporteId] FOREIGN KEY ([DeporteId]) REFERENCES [Deportes] ([Id]) ON DELETE CASCADE
  );
  GO
  
  
  CREATE TABLE [Reservas] (
      [Id] int NOT NULL IDENTITY,
      [Fecha] datetime2 NOT NULL,
      [Hora] int NOT NULL,
      [SocioId] int NOT NULL,
      [PistaId] int NOT NULL,
      CONSTRAINT [PK_Reservas] PRIMARY KEY ([Id]),
      CONSTRAINT [FK_Reservas_Pistas_PistaId] FOREIGN KEY ([PistaId]) REFERENCES [Pistas] ([Id]) ON DELETE CASCADE,
      CONSTRAINT [FK_Reservas_Socios_SocioId] FOREIGN KEY ([SocioId]) REFERENCES [Socios] ([Id]) ON DELETE CASCADE
  );
  GO
  
  
  IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'ConcurrencyStamp', N'Name', N'NormalizedName') AND [object_id] = OBJECT_ID(N'[AspNetRoles]'))
      SET IDENTITY_INSERT [AspNetRoles] ON;
  INSERT INTO [AspNetRoles] ([Id], [ConcurrencyStamp], [Name], [NormalizedName])
  VALUES (N'f406bd6e-0de4-4679-874d-33bcb9c6861b', N'1932f13f-abad-4066-a507-488edca40182', N'admin', N'admin');
  IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'ConcurrencyStamp', N'Name', N'NormalizedName') AND [object_id] = OBJECT_ID(N'[AspNetRoles]'))
      SET IDENTITY_INSERT [AspNetRoles] OFF;
  GO
  
  
  CREATE INDEX [IX_AspNetRoleClaims_RoleId] ON [AspNetRoleClaims] ([RoleId]);
  GO
  
  
  CREATE UNIQUE INDEX [RoleNameIndex] ON [AspNetRoles] ([NormalizedName]) WHERE [NormalizedName] IS NOT NULL;
  GO
  
  
  CREATE INDEX [IX_AspNetUserClaims_UserId] ON [AspNetUserClaims] ([UserId]);
  GO
  
  
  CREATE INDEX [IX_AspNetUserLogins_UserId] ON [AspNetUserLogins] ([UserId]);
  GO
  
  
  CREATE INDEX [IX_AspNetUserRoles_RoleId] ON [AspNetUserRoles] ([RoleId]);
  GO
  
  
  CREATE INDEX [EmailIndex] ON [AspNetUsers] ([NormalizedEmail]);
  GO
  
  
  CREATE UNIQUE INDEX [UserNameIndex] ON [AspNetUsers] ([NormalizedUserName]) WHERE [NormalizedUserName] IS NOT NULL;
  GO
  
  
  CREATE INDEX [IX_Pistas_DeporteId] ON [Pistas] ([DeporteId]);
  GO
  
  
  CREATE INDEX [IX_Reservas_PistaId] ON [Reservas] ([PistaId]);
  GO
  
  
  CREATE INDEX [IX_Reservas_SocioId] ON [Reservas] ([SocioId]);
  GO
  
  
  