Visual Studio Database Project and aspnet_regsql.exe

I am using a visual studio database project to manage database changes for a website. I would like to use the membership / role model created by the aspnet_regsql tool to control access to the website.

So far, I have run aspnet_regsql before deploying the database, so that the database project merges specific website tables into a database. I have learned how to include aspnet_ tables in a database project, but cannot figure out how to do this.

Has anyone ever tried this? Are there any good reasons not to do this?

+3
source share
1 answer

, . , , , Pro ASP.Net 4.0 . , , script . ... .

, RedGate Compare, ... , ... YMMV.

, aspnet_regsql. VS2010 . Schema Objects Schema Objects. , , .

Database.sqlpermissions .

, - script.

-- Add 6 rows to [dbo].[aspnet_SchemaVersions]
IF NOT EXISTS (SELECT * FROM [dbo].[aspnet_SchemaVersions] WHERE [Feature] = (N'common') AND [CompatibleSchemaVersion] = N'1')
  BEGIN
    INSERT INTO [dbo].[aspnet_SchemaVersions] ([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES (N'common', N'1', 1)
  END

IF NOT EXISTS (SELECT * FROM [dbo].[aspnet_SchemaVersions] WHERE [Feature] = (N'health monitoring') AND [CompatibleSchemaVersion] = N'1')
  BEGIN  
    INSERT INTO [dbo].[aspnet_SchemaVersions] ([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES (N'health monitoring', N'1', 1)
  END

IF NOT EXISTS (SELECT * FROM [dbo].[aspnet_SchemaVersions] WHERE [Feature] = (N'membership') AND [CompatibleSchemaVersion] = N'1')
  BEGIN   
    INSERT INTO [dbo].[aspnet_SchemaVersions] ([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES (N'membership', N'1', 1)
  END

IF NOT EXISTS (SELECT * FROM [dbo].[aspnet_SchemaVersions] WHERE [Feature] = (N'personalization') AND [CompatibleSchemaVersion] = N'1')
  BEGIN 
    INSERT INTO [dbo].[aspnet_SchemaVersions] ([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES (N'personalization', N'1', 1)
  END

IF NOT EXISTS (SELECT * FROM [dbo].[aspnet_SchemaVersions] WHERE [Feature] = (N'profile') AND [CompatibleSchemaVersion] = N'1')
  BEGIN 
    INSERT INTO [dbo].[aspnet_SchemaVersions] ([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES (N'profile', N'1', 1)
  END

IF NOT EXISTS (SELECT * FROM [dbo].[aspnet_SchemaVersions] WHERE [Feature] = (N'role manager') AND [CompatibleSchemaVersion] = N'1')
  BEGIN 
   INSERT INTO [dbo].[aspnet_SchemaVersions] ([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES (N'role manager', N'1', 1)
  END
+2

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


All Articles