1、問題web
使用ef codefirst開發,沒法建立數據庫的問題,以下提示數據庫
Server Error in '/' Application. 在多語句事務內不容許使用 CREATE DATABASE 語句。 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: 在多語句事務內不容許使用 CREATE DATABASE 語句。 Source Error: Line 32: */ Line 33: public ZmBlogDbContext(string nameOrConnectionString) Line 34: : base(nameOrConnectionString) Line 35: { Line 36:
2、解決方法
這是 EF 拋出的異常,只要先建立好數據庫就能夠了spa
create database [ZmBlog]code
提示:orm
這個錯誤是在第一次運行abp出現的,建立數據庫後,這時要使用 update-database 進行數據遷移,不然基礎數據是空的blog
解決方案二:事務
一、建立ABP空模板後,按F5,生成報:在多語句事務內不容許使用 CREATE DATABASE 語句錯誤ip
解決辦法:打開Nugut程序包管理器控制檯,默認項目選擇:EntityFramework;輸入:Update-Database -Verboseci
二、若是出現:Cannot determine a valid start-up project. Using project 'MyPro.EntityFramework' instead. Your configuration file and working directory may not be set as expected. Use the -StartUpProjectName parameter to set one explicitly. Use the -Verbose switch for more information.開發
解決辦法:Update-Database -StartUpProjectName "MyPro.Web" 經過StartUpProjectName指定啓動項目