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指定启动项目