我在这里遇到这种"神秘"问题.我目前正在使用我的ASP.NET MVC 3应用程序使用Entity Framework 4.1 Code First方法,它工作得很好,直到昨天......
发生了一些非常糟糕的事情导致我的Database.SetInitializer停止工作.解释:
我有这个简单的模型
public class User
{
public int Id { get; set; }
public int RoleId { get; set; }
[Required]
[StringLength(50)]
[DataType(DataType.Text)]
public string Login { get; set; }
[Required]
[StringLength(150)]
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
[Required]
[StringLength(32)]
[DataType(DataType.Password)]
public string Password { get; set; }
[DataType(DataType.DateTime)]
public DateTime RegisteredDate { get; set; }
public virtual Role Role { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是我的DbContext
public class MyContext : DbContext …Run Code Online (Sandbox Code Playgroud) code-first sql-server-2008 ef-code-first entity-framework-4.1 asp.net-mvc-3
我试图在我的python脚本中模拟HTTP服务器,但它失败了.这是我在做的事情:
import bottle
from restclient import GET
from threading import Thread
@bottle.route("/go")
def index():
return "ok"
server = Thread(target = bottle.run)
server.setDaemon(True)
server.start()
print "Server started..."
response = GET("http://127.0.0.1:8080/go")
assert response.body == "ok"
print "Done..."
Run Code Online (Sandbox Code Playgroud)
基本上我试图在一个单独的线程中启动带有1个测试路由的bottle.py http服务器,然后模拟它的响应.
但它不会起作用.服务器没有在一个单独的线程中启动,所以我总是在尝试请求时得到"errno 111 connection refused".
所以问题是:如何解决?有没有其他方法来模拟http服务器?