首先使用Mvc3.0代码时,Sql2008是否可以自动创建表? [英] Does Sql2008 can auto create table when work with Mvc3.0 code first ?

查看:42
本文介绍了首先使用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 .

推荐答案

SQL永远不会为您自动创建"表.您必须告诉它明确执行此操作.

我真的不认为这是您的问题:上面的代码未引用任何表,因此不会引发您描述的错误.
您实际使用的是什么代码会导致此问题?
SQL will never "auto create" a table for you. You have to tell it to do it explicitly.

I don''t really think that is your problem: Your code above does not refer to any table, so it cannot be raising the error you describe.
What code are you actually using that does cause this problem?


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>]


http://www.microsofthttp://msdn.microsoft.com/zh-cn/library/ms365247.aspx =>重要的东西页面
http://www.microsoft.com/download/zh-CN/details.aspx?id=23650 =>链接到SSMSE2k8(x64或x86,请按个人喜好"选择)
http://sqlserversamples.codeplex.com/=>链接到AdventureWorks数据库示例

~~~~~~~~~~

此外,无论位于何处,都可以下载"SQL Server 2008 R2组合帮助集合" ...

而且"您准备好学习T-SQL!

忠告:从您指向此页面的日期开始,斯科特·古斯里(Scott Guthries)在2010年12月发布了ASP.NET MVC,但这并不是说2010年12月确实是一个过时的日期,但是我在THEN到SQL2000的链接上遇到了问题(Ecod , 掌管!);可能会/应该在2010年12月的时间范围内对SSMS Express R2进行更适当的引用,是吗?

P.S.

如果在今天我们知道的Visual Studio 2005发行版和x64平台的调试之间,Microsoft在这段时间内做过任何事情,那么它将创建这个不错的SQL Server帮助卷.哦,给我们SSMSE2k8(化身为……)!
http://www.microsofthttp://msdn.microsoft.com/en-us/library/ms365247.aspx => crucial stuff page
http://www.microsoft.com/download/en/details.aspx?id=23650 => link to SSMSE2k8 (x64 or x86, take ''yer pick)
http://sqlserversamples.codeplex.com/ => link to AdventureWorks database samples

~~~~~~~~~~

In addition, download the "SQL Server 2008 R2 Combined Help Collection", whereever THAT is located ...

And ''yer ready to learn T-SQL!

Advise: Judging from the date of this page you point to, Scott Guthries'' ASP.NET MVC announcement of Dec 2010, and not that Dec 2010 is a stale date really, but I have issues with a link found THEN to SQL2000 (Ecod, man!); possibly a more appropriate reference would have been/should be made to SSMS Express R2 in a Dec 2010 time frame, yes?

P.S.

If there ever was anything that Microsoft did right in the time period bewteen the release of Visual Studio 2005 and the debugging of the x64 platform as we know it today, it was creating this nice SQL Server help volume. Oh, and giving us SSMSE2k8 (in all it''s incarnations ...)!


这篇关于首先使用Mvc3.0代码时,Sql2008是否可以自动创建表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆