tags:

views:

288

answers:

2

I'm creating a .dbml file from a database. My "property" table has foreign keys to the "county" table and to a "propertysource" table.

When code is generated, Property.Source is defined as a PropertySource type, but Property.County is defined as an int, instead of a County type.

I'm afraid I don't have the experience with LINQ to SQL to understand what's happening here or why that is or how to fix it. I can't find anything obvious about my schema that might cause this. How can I get the automagically generated code to recognize the County property of the Property object is a County type?

+1  A: 

When you open the dbml designer make sure you have a diagram that shows two arrows from the Property class: one arrow going to the County class, and another going to the PropertySource class. Also, you should have those three classes in your designer as well.

If you don't see the object model that way then there is probably something wrong with the way your database schema is set up.

I would check to make sure your foreign keys are set up correctly.

Joseph
The diagram looks correct; arrows in the right places. All three entities are in the designer. Foreign keys are set up correctly.
The Demigeek
Could you take a pic of the diagram and include it in your question? I have a feeling it has to do with your properties and how they're set up but i can't be sure unless I can see it.
Joseph
+1  A: 

When you click on the Property in the DBML file, you can modify it's Type using the Properties window. In the Properties window, there's a field for Type. You can select some of the standard Types from the dropdown, or enter in your own custom Type using it's full name, ie. "MyProject.Location.Country.CountryType", etc.

Be sure to rebuild your project before you try to access this in IntelliSense. Hope this helps!

mbmccormick