I'm trying to create a user in SQL Server. I can create the user fine and then I grant that user some privileges. Here is the code:
CREATE LOGIN TestLogin WITH password='abc';
-- Now add user to database
USE TestDB;
CREATE USER TestUser FOR LOGIN TestLogin;
GO
use [TestDB]
GO
GRANT INSERT TO [TestUser]
GO
use [TestDB]
GO
GRANT SELECT TO [TestUser]
GO
use [TestDB]
GO
GRANT UPDATE TO [TestUser]
GO
use [TestDB]
GO
DENY DELETE TO [TestUser]
GO
After this I want to use this user in my web.config file.
<add name="DBConnectionString"
connectionString="Server=tcp:abc.database.windows.net;Database=TestDB;User ID=TestLogin;Password=abc;Trusted_Connection=False;Encrypt=True;MultipleActiveResultSets=True;"
providerName="System.Data.SqlClient" />
My question is: in the web.config file I have to use the LOGIN user. When I apply migrations, I don't want to run any DELETE statements so I created a USER and denied him the access. Can I use this user in the web.config file?
My goal is that when migrations are applied I don't want to execute DELETE. Will my approach work or what should I change?