This project is read-only.

LINQ2SQL - putting models in own assembly/Project?

Nov 25, 2010 at 8:45 AM

Hi there,

 

I followed the instructions for adding linq2sql to my vs 2008 project. All went well but the DBML and the models are together.. I wanted to have my models separate so i copied the the tt file to my model project and now everything works with a small change in the tt file.

 

generator.DbmlFile = @"..\MyRepository.Repository\MyData.dbml";

 

1 problem though, the consturctor of the tts file on the datacontext it is calling my repository (original project). I can edit it but when its regenerated its reedited. Am i doing something wrong

public MyDataDataContext()
            : base(MyRepository.Repository.Properties.Settings.Default.DATAConnectionString)
        {

This is wrong, so i have to change it to.

: base(Properties.Settings.Default.DATAConnectionString)

 

and now it works.

Also under the original MyData.dbml although i deleted the TT file and moved it to another project its recreated but its pretty much empty. Just has this

 

<#@ template language="C#" hostspecific="True" debug="True" #>
<#@ output extension="txt" #>
<#@ include file="T4Toolbox.tt" #>

i would really appreciated any feedback of what i am doing wrong or if there is a workaround.

 

Thanks in advance

 

 

<!-- qtl { position: absolute; border: 1px solid #cccccc; -moz-border-radius: 5px; opacity: 0.2; line-height: 100%; z-index: 999; direction: ltr; } qtl:hover,qtl.open { opacity: 1; } qtl,qtlbar { height: 22px; } qtlbar { display: block; width: 100%; background-color: #cccccc; cursor: move; } qtlbar img { border: 0; padding: 3px; height: 16px; width: 16px; cursor: pointer; } qtlbar img:hover { background-color: #aaaaff; } qtl>iframe { border: 0; height: 0; width: 0; } qtl.open { height: auto; } qtl.open>iframe { height: 200px; width: 300px; } -->

Nov 27, 2010 at 7:01 PM

The name of the settings class is stored in the DBML file. Your .DBML file and your DataContext class must be in the same project.

Oleg