CREATE DATABASE statement not allowed within multi-statement transaction.
When I first reported this mistake, I went to the mother of a search.
Others are reported errors when adding data to the SQL Server admin interface.
And I, in the ASP. NET MVC program started, when the first visit, throw the exception, so other people's solution is not suitable for me.
Later, after a toss-up, accidentally happened to solve the problem.
Later, we tried to reproduce the problem in order to confirm the solution.
The general reason is that there is already an instance connected to your database, and when the ASP. NET MVC program starts, it also goes (in the form of a database file) to connect.
This is mainly because the database connection string is written like this: Server= (LocalDB) \mssqllocaldb; attachdbfilename=| Datadirectory|\mydatabase.mdf; Trusted_connection=true;
And my visual Studio 2015 SQL Server Object Explorer is just connected to this localdb instance, so ... Throw an exception ...
This exception usually occurs when connecting to an offline database file and LocalDB, and be careful not to connect again if an instance is already connected.
[Solutions] CREATE DATABASE statement not allowed within multi-statement transaction.