w*s 发帖数: 7227 | 1 Hi 大牛们,
i downloaded AdventureWorks2012_Data.mdf,
i can open it using sql server 2012 express.
Now i'm following the book trying to create a c# project connect to it,
(the book uses NorthWind db file, i cannot open it as it's not for sql 2012)
at step 9, i choosed my db file, i click "ok", but nothing happens other
than hearing a bell.
Any help appreciated !
1. Create a new console application project called BegVCSharp_24_1_
FirstLINQtoDatabaseQuery in the
directory C:BegVCSharpChapter24.
2. Press OK to create the project.
3. To add the LINQ to Entities data source for the Northwind database, go to
the Solution Explorer pane,
click the BegVCSharp_24_1_FirstLINQtoDatabaseQuery C# project, then select
Project ➪ Add New
Data Source from the menu bar.
4. In the Choose a Data Source Type dialog box, select Database. Click Next.
5. In the Choose a Database Model dialog box, select Entity Data Model.
Click Next.
6. In the Choose Model Contents dialog box, select Generate From Database.
Click Next.
7. In the Choose Your Data Connection dialog box, select New Connection.
8. In the Choose Data Source dialog box, select Microsoft SQL Server
Database File. Click Continue.
702 ❘ CHAPTER 24 APPLYING LINQ
9. In the Connection Properties dialog box, click the Browse button next to
the Database File Name (this
works for a new or existing textbox). Browse to the C:
BegVCSharpChapter24Database directory
and select Northwind.MDF as the database fi le name. Click OK to close the
windows to fi nish importing
the entity model.
10. Click Next. A popup will ask whether you want to copy the database fi le
to your project. Choose No.
11. In the Choose Your Database Objects And Settings dialog box (Entity Data
Model Wizard), expand the
Tables control, dbo control, and check Customers, Orders, and Order Details.
Click Finish and you will
now see a diagram of your entity data objects in a window labeled Model1.
edmx, as shown in Figure
24-1. If VS2012 asks if the location is trusted, answer Yes. | n*****0 发帖数: 434 | 2 Have you tried to click on the Test Connection button? Did it work? | w*s 发帖数: 7227 | 3 same thing, only hear bell.
i wonder if VS 2012 express has limitations.
【在 n*****0 的大作中提到】 : Have you tried to click on the Test Connection button? Did it work?
| c*********e 发帖数: 16335 | 4 這個东西写起来复杂,做起来非常容易。不知道你是哪步做错了。
2012)
【在 w*s 的大作中提到】 : Hi 大牛们, : i downloaded AdventureWorks2012_Data.mdf, : i can open it using sql server 2012 express. : Now i'm following the book trying to create a c# project connect to it, : (the book uses NorthWind db file, i cannot open it as it's not for sql 2012) : at step 9, i choosed my db file, i click "ok", but nothing happens other : than hearing a bell. : Any help appreciated ! : 1. Create a new console application project called BegVCSharp_24_1_ : FirstLINQtoDatabaseQuery in the
| w*s 发帖数: 7227 | 5 ok, i used vs 2012 ultimate, not express version, it's getting better.
1. i have a existing c# project
2. connection to exiting mssql Mydb.mdf from the top steps i posted above.
now in my main.cs i try to do a test by adding 1 line,
MydbEntities mydbEntities = new MydbEntities();
my db file is Mydb.mdf
during build it says "MydbEntities" could not be found.
what should i do from here ?
thanks for helping a dummy ! | c*********e 发帖数: 16335 | 6 MydbEntities是你的class名字?那你要import MydbEntities;
【在 w*s 的大作中提到】 : ok, i used vs 2012 ultimate, not express version, it's getting better. : 1. i have a existing c# project : 2. connection to exiting mssql Mydb.mdf from the top steps i posted above. : now in my main.cs i try to do a test by adding 1 line, : MydbEntities mydbEntities = new MydbEntities(); : my db file is Mydb.mdf : during build it says "MydbEntities" could not be found. : what should i do from here ? : thanks for helping a dummy !
| H*******g 发帖数: 6997 | |
|