{"id":770,"date":"2007-09-03T03:18:00","date_gmt":"2007-09-03T03:18:00","guid":{"rendered":"\/blogs\/bobb\/post\/Using-LINQ-to-SQL-and-EDM-with-SQL-Server-2008.aspx"},"modified":"2007-09-03T03:18:00","modified_gmt":"2007-09-03T03:18:00","slug":"using-linq-to-sql-and-edm-with-sql-server-2008","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/","title":{"rendered":"Using LINQ to SQL and EDM with SQL Server 2008"},"content":{"rendered":"<p>\nI&#39;ve been trying out LINQ for SQL and the Entity Data Model (EDM) latest betas with some &quot;non-traditional&quot; data sources. Namely SQL Server 2008 (CTP4) and SQL Server Compact Edition 3.5. I&#39;ll cover using SQL Server 2008 CTP in this blog entry, and using SQLCE 3.5 in the next one.\n<\/p>\n<p>\nUsing SQL Server 2008 data sources doesn&#39;t work with the built-in designers in Visual Studio 2008 beta 2. Adding new &quot;LINQ to SQL classes&quot; produces an empty design surface onto which you can drag items from Server Explorer. Problem is, you can&#39;t make a Server Explorer Data Connection for a SQL Server 2008 database &quot;only versions 2005 and before are currently supported. The EDM Wizard actually includes &quot;Use this selection to connect to Microsoft SQL Server 2000 or 2005&#8230;&quot; when you attempt to create a Data Connection. Not SQL Server 2008. So there&#39;s no LINQ to SQL or EDM designer support. Or Server Explorer support, for that matter.\n<\/p>\n<p>\nBut each of the mapping products comes with a command line tool as well. LINQ to SQL uses SQLMetal, while the EDM uses EDMgen.\n<\/p>\n<p>\nUsing the command line tools, I was able to generate the appropriate artifacts (and use them) for SQL Server 2008. I can even load the artifacts (.dbml or .edmx) files into the Visual Studio designer after they were generated from the command line and edit them. Very cool.\n<\/p>\n<p>\nI then did an experiment to see if LINQ to SQL or EDM supports the new data types in SQL Server 2008, namely, the new date\/time-related types and the hierarchyID, which is implemented as a SQLCLR UDT.\n<\/p>\n<p>\nSQLmetal did not produce an error or warning on the date\/time types, but it did create definitions for the new data types as &quot;NVarChar&quot; with appropriate lengths. Using these definitions in LINQ code prints database-correct values, albeit as strings. Haven&#39;t tried an insert\/update\/delete yet. I had less success with hierarchyID, this produces the message:\n<\/p>\n<p>\nwarning SQM1021: Unable to extract column &#39;c1&#39; of Table &#39;dbo.h1&#39; from SqlServer<br \/>\nbecause the column&#39;s DbType is a user-defined type (UDT).\n<\/p>\n<p>\nSQLmetal then error&#39;d out and didn&#39;t generate a dbml file at all.\n<\/p>\n<p>\nTrying date\/time-related data types with EDMgen produces errors indicating that the date, time, datetime2, datetimeoffset aren&#39;t supported. Neither are SQLCLR UDTs,&nbsp;hierarchyID&nbsp;is reported as date type &lt;unknown&gt;.\n<\/p>\n<p>\nWell, these are still beta. That&#39;s all for now.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#39;ve been trying out LINQ for SQL and the Entity Data Model (EDM) latest betas with some &quot;non-traditional&quot; data sources. Namely SQL Server 2008 (CTP4) and SQL Server Compact Edition 3.5. I&#39;ll cover using SQL Server 2008 CTP in this blog entry, and using SQLCE 3.5 in the next one. Using SQL Server 2008 data [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29],"tags":[],"class_list":["post-770","post","type-post","status-publish","format-standard","hentry","category-data-access","category-sql-server-2008"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using LINQ to SQL and EDM with SQL Server 2008 - Bob Beauchemin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using LINQ to SQL and EDM with SQL Server 2008 - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"I&#039;ve been trying out LINQ for SQL and the Entity Data Model (EDM) latest betas with some &quot;non-traditional&quot; data sources. Namely SQL Server 2008 (CTP4) and SQL Server Compact Edition 3.5. I&#039;ll cover using SQL Server 2008 CTP in this blog entry, and using SQLCE 3.5 in the next one. Using SQL Server 2008 data [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2007-09-03T03:18:00+00:00\" \/>\n<meta name=\"author\" content=\"Bob Beauchemin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bob Beauchemin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/\",\"name\":\"Using LINQ to SQL and EDM with SQL Server 2008 - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2007-09-03T03:18:00+00:00\",\"dateModified\":\"2007-09-03T03:18:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Data Access\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/data-access\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Using LINQ to SQL and EDM with SQL Server 2008\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\",\"name\":\"Bob Beauchemin\",\"description\":\"SQL Server Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\",\"name\":\"Bob Beauchemin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"caption\":\"Bob Beauchemin\"},\"sameAs\":[\"http:\/www.sqlskills.com\/blogs\/bobb\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using LINQ to SQL and EDM with SQL Server 2008 - Bob Beauchemin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/","og_locale":"en_US","og_type":"article","og_title":"Using LINQ to SQL and EDM with SQL Server 2008 - Bob Beauchemin","og_description":"I&#39;ve been trying out LINQ for SQL and the Entity Data Model (EDM) latest betas with some &quot;non-traditional&quot; data sources. Namely SQL Server 2008 (CTP4) and SQL Server Compact Edition 3.5. I&#39;ll cover using SQL Server 2008 CTP in this blog entry, and using SQLCE 3.5 in the next one. Using SQL Server 2008 data [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/","og_site_name":"Bob Beauchemin","article_published_time":"2007-09-03T03:18:00+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/","name":"Using LINQ to SQL and EDM with SQL Server 2008 - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2007-09-03T03:18:00+00:00","dateModified":"2007-09-03T03:18:00+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-linq-to-sql-and-edm-with-sql-server-2008\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"Data Access","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/data-access\/"},{"@type":"ListItem","position":3,"name":"Using LINQ to SQL and EDM with SQL Server 2008"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/","name":"Bob Beauchemin","description":"SQL Server Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e","name":"Bob Beauchemin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","caption":"Bob Beauchemin"},"sameAs":["http:\/www.sqlskills.com\/blogs\/bobb\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/comments?post=770"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/770\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}