views:

116

answers:

1

Hello,

I'm experiencing a problem while working with all my projects. I don't get Intellisense with Linq2Sql and, when I write partial classes in the model folder, properties created by the Linq2Sql designer are not recognized by the partial classes. So, I'm trying to rule out all the possible sources of the problem.

I have 2 cases: (i) create a .mdf file under App_Data and (2) create a .dbo file in SQL EXPRESS 2005. Now, when I create the DataContext file (by dragging and dropping tables in the designer), are there going to work the same way? Or do I need to expect unanticipated behavior?

Thanks

A: 

App_Data is only used in ASP.NET apps and is only meant to store the physical database file (the ASP.NET worker process always has read/write access to that folder). For regular apps you should be dropping any database file in common locations that everyone has rights to (or everyone who is using the app).

Put your DBML (linq to sql classes file) in the subfolder of your project where it makes sense vis a vis the namespace. For instance, you'd put it under MyApp/Data or MyApp/Repository or MyApp/Models, etc.

In the .dbml designer, check the properties tool window and make sure you specify the name and namespace for the data context and the entities. Your entity partial classes MUST be in the SAME namespace or the compiler won't know to put them together.

Will
When I look at the Properties tool, I see this: (i) Name = TheBeerHouseDataContext (2) Inheritence modifier = None. The rest of the properties are empty (Context Name, Entity NameSpace, Connection String). Is that properties you mean?
Richard77
Name is the name of the context (e.g., TheBeerHouseDataContext.SubmitChanges()). Entity namespace is the namespace of all the entity classes (TheBeerHouse.Data.Beer b = TheBeerHouseDataContext.Beers.FirstOrDefault())
Will
Shoot, I said "mdf" when I meant dbml... fixing.
Will
Although I still have questions, I prefer first to give you credit for your help. Indeed, it works now: (i) I don't get the error anymore and (ii) I get also the full Intellisense. To avoid creating unnecessary threads, I prefer to ask u this question here. Can u tell me if there is an option to pluralize tables created in the Liq designer? (e.g. Dinners -> Dinner) Thanks
Richard77
Not sure. If it is, its on the propreties of the dbml or on the entities themselves...
Will