This is really annoying...and I know it is something extremely simple...
1. I create a new Dynamic Data project.
2. I add a LINQ-to-SQL class and drag and drop some tables onto the class.
3. I open the global.asax.vb and uncomment the line:
DefaultModel.RegisterContext(GetType(YourDataContext), New ContextConfiguration() With {.ScaffoldAllTables = True})
I remove YourDataContext and replace it with the DataContext from my LINQ-to-SQL class:
DefaultModel.RegisterContext(GetType(NorthwindDataContext), New ContextConfiguration() With {.ScaffoldAllTables = True})
I then try to debug/build/etc. and receive the following error:
Type 'NorthwindDataContext' is not defined
Why is it not defined? It seems like its not recognizing I created the DBML file.
views:
132answers:
2
A:
Does your project compile? I am guessing you are missing the namespace to your data context. Something like this:
model.RegisterContext(typeof(MyApp.MyNamespace.NorthwindDataContext),
new ContextConfiguration() { ScaffoldAllTables = true });
Raj Kaimal
2010-05-29 00:37:07
See, that is the issue. I have a line like that: DefaultModel.RegisterContext(GetType(phonesDataContext), New ContextConfiguration() With {.ScaffoldAllTables = True})But...that gives an error...but I know the data context exists!
davemackey
2010-06-01 21:15:25
Did you add the *namespace* to your datacontext? MyApp.MyNamespace.NorthwindDataContext
Raj Kaimal
2010-06-01 21:30:35
A:
This is a very strange issue and I am still not sure that I have entirely fixed the issue. But, here is what I think I have learned: 1. If you are creating a New Project in VS2010 you must place the LINQ-to-SQL DBML file in the root project directory. 2. If you are creating a new Web Site in VS2010 you must place the LINQ-to-SQL DBML file in a newly created App_Code directory. 3. If you place it in the wrong place, scrap the project and start over - it doesn't seem to work even if you move the files to the correct location or recreate them in the correct location. Dave.
davemackey
2010-06-02 18:42:18