Basically its what the title says. This is my code.
USE Assignment2;
GO
/* Player View (2 marks)
Create a view which shows the following details of all
You may also run into this issue if trying to execute scripts from Entity Framework migrations. I think this is due to EF running those scripts in a transaction (as mentioned in another answer to this question). You can get round that with this type of syntax:
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[V_MovieActors]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[V_MovieActors]
AS
SELECT NEWID() AS Id, dbo.Movie.Title, dbo.Movie.ReleaseDate, dbo.Actor.FirstName + '' '' + dbo.Actor.LastName AS Actor, dbo.Actor.DateOfBirth
FROM dbo.Actor INNER JOIN
dbo.Movie ON dbo.Actor.Id = dbo.Movie.Actor_Id
'
Which turns the whole thing into a single command for SQL to execute. That approach comes from this very useful article Using SQL Views With Entity Framework Code First by Morgan Kamoga.