本文介绍了首先使用Mvc3.0代码时,Sql2008是否可以自动创建表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是迈克尔
我确定sql2008可以与mvc3.0一起使用.但是我不知道如何在web.config中编写连接字符串.
这是我的连接字符串
hi i''m Michael
i''m sure the sql2008 can work with mvc3.0 . but i''m don''t know how to write connection string in web.config .
this''s my connection string
<add name="MovieDBContext">
connectionString="Data Source=bj-michael;Initial Catalog=Movie;User Id=sa;Password=`1qaz2wsx;"
providerName="System.Data.SqlClient" /> </add>
但始终抛出对象名称"dbo.Movies"无效..
但是如果我在数据库影片中创建相同的表格影片.那没关系.
所以我想知道,带有mvc3.0的sql2008不会自动创建表吗?谢谢.
but is allways throw Object name ''dbo.Movies'' invalid..
but if i create an same table movies in database movie . then it''s alright .
so i wanna know ,does sql2008 with mvc3.0 will not auto create table ? thanks .
推荐答案
i'm sorry , I described is not clear enough 。 :)
first , Asp.net mvc3.0 has a mechanism, that code first. If work with CE4.0 used together, can need not create database, also need not creating tables. But i wanna work with sqlserver . i don't know how to do it .
look this
<a href="http://weblogs.asp.net/scottgu/archive/2010/12/08/announcing-entity-framework-code-first-ctp5-release.aspx">http://weblogs.asp.net/scottgu/archive/2010/12/08/announcing-entity-framework-code-first-ctp5-release.aspx</a>[<a href="http://weblogs.asp.net/scottgu/archive/2010/12/08/announcing-entity-framework-code-first-ctp5-release.aspx" target="_blank" title="New Window">^</a>]
这篇关于首先使用Mvc3.0代码时,Sql2008是否可以自动创建表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!