Search Results

Search found 139 results on 6 pages for 'dbml'.

Page 1/6 | 1 2 3 4 5 6  | Next Page >

  • Linq to Sql Data class in dbml

    - by Simon
    I am abit curious about dbml.... Should I create one dbml file for one database or separated into different parts e.g. User dbml (only tables relate to users) etc? When I do this I will have abit of problems. Assume the User dbml has a User table and if the Order dbml has a User table as well, this won't be allowed if the entity namespace are the same. If I have set a different entity namespace for each of the dbml, it works but this will gives me a different entity of User table. When a single data returns to Business Logic layer, there is a difficulty of knowing which entity namespace of the user table to be used. If I built one dbml file instead of having separate dbml, will single dbml appear slower than the separated dbml version when fetching the data from the database.

    Read the article

  • How can I switch between 2 Connection Strings in my Web.Config (Activate one for DBML)

    - by Alex
    Hello! I have two connection strings (both in Web.Config: CS_Local and CS_Production) for my DBML (Linq to SQL). In my Global.Asax/Application_Start I run some production preparation methods if the request is non-local (!HttpContext.Current.Request.IsLocal). Within that part, I'd also like to change the current connection string used by my DBML from the standard CS_Local to CS_Production. How would I do that? Some help please..

    Read the article

  • .DBML file and LINQ to SQL

    - by Rishabh Ohri
    In my DBML file I have mapped some tables and stored procedures, and the stored procedures return type is ISingleResult . T is some mapped table. But I want to take the data into my own created entities rather than LINQ to SQL created entites. The entites created by me are also the same as the mapped table entities and their use lies when we send data across the a web service. So , how can I proceed by creating a wrapper around the DBML file so that I always get data in my own created entites.

    Read the article

  • C# dbml stops linking tables to code

    - by Philip
    I am having occasional trouble with my C# dbml where it starts not linking properly. I do not know how to replicate the exact cause of the problem, it was working perfectly until I changed a database table and then deleted the table and readded it with the new schema. The error message I get is "The type or namespace name 'tbl' could not be found (are you missing a using directive or an assembly reference?) The only fix I have found is to make a new dbml readd the tables. Any ideas what to do or why this is happening?

    Read the article

  • Weird mapping error in linq-to-sql dbml file in VS2010

    - by rwwilden
    Since I switched to VS2010, several times a day I get a compilation error in my dbml file: DBML1005: Mapping between DbType 'bigint' and Type 'MyNamespace.SecurityToken' in Column 'SecurityToken' of Type 'Employee' is not supported When I restart VS2010 the error disappears. I have no problems running my application using this dbml file (specifically, there are no problems getting correct values inside the SecurityToken property of Employee objects). The SecurityToken property is of an enum type defined as follows: [Flags] public enum SecurityToken : long { None = 1, Admin = 2, ...... } The SecurityToken column in the database is of type bigint. Am I missing something? It's especially weird that the error only happens sometimes, when I'm writing code that isn't related at all to the LINQ model.

    Read the article

  • Sync LINQ-to-SQL DBML schema with SQL Server database

    - by Maxim Z.
    After creating a SQL Server 2008 database, I made a Linq-to-SQL schema in Visual Studio. Next, in the .dbml visual editor (in Visual Studio), I added PK-to-FK and PK-to-PK associations to the schema. How do I copy those associations that I created in Visual Studio over to the database? In other words, how do I sync with the DB?

    Read the article

  • Linq To SQL: Behaviour for table field which is NotNull and having Default value or binding

    - by kaushalparik27
    I found this something interesting while wandering over community which I would like to share. The post is whole about: DBML is not considering the table field's "Default value or Binding" setting which is a NotNull. I mean the field which can not be null but having default value set needs to be set IsDbGenerated = true in DBML file explicitly.Consider this situation: There is a simple tblEmployee table with below structure: The fields are simple. EmployeeID is a Primary Key with Identity Specification = True with Identity Seed = 1 to autogenerate numeric value for this field. EmployeeName and their EmailAddress to store in rest of 2 fields. And the last one is "DateAdded" with DateTime datatype which doesn't allow NULL but having Default Value/Binding with "GetDate()". That means if we don't pass any value to this field then SQL will insert current date in "DateAdded" field.So, I start with a new website, add a DBML file and dropped the said table to generate LINQ To SQL context class. Finally, I write a simple code snippet to insert data into the tblEmployee table; BUT, I am not passing any value to "DateAdded" field. Because I am considering SQL Server's "Default Value or Binding (GetDate())" setting to this field and understand that SQL will insert current date to this field.        using (TestDatabaseDataContext context = new TestDatabaseDataContext())        {            tblEmployee tblEmpObjet = new tblEmployee();            tblEmpObjet.EmployeeName = "KaushaL";            tblEmpObjet.EmployeeEmailAddress = "[email protected]";            context.tblEmployees.InsertOnSubmit(tblEmpObjet);            context.SubmitChanges();        }Here comes the twist when application give me below error:  This is something not expecting! From the error it clearly depicts that LINQ is passing NULL value to "DateAdded" Field while according to my understanding it should respect Sql Server's "Default value or Binding" setting for this field. A bit googling and I found very interesting related to this problem.When we set Primary Key to any field with "Identity Specification" Property set to true; DBML set one important property "IsDbGenerated=true" for this field. BUT, when we set "Default Value or Biding" property for some field; we need to explicitly tell the DBML/LINQ to let it know that this field is having default binding at DB side that needs to be respected if I don't pass any value. So, the solution is: You need to explicitly set "IsDbGenerated=true" for such field to tell the LINQ that the field is having default value or binding at Sql Server side so, please don't worry if i don't pass any value for it.You can select the field and set this property from property window in DBML Designer file or write the property in DBML.Designer.cs file directly. I have attached a working example with required table script with this post here. I hope this would be helpful for someone hunting for the same. Happy Discovery!

    Read the article

  • creating Linq to sqlite dbml from DbLinq source code

    - by Veer
    Hi All, I tried to create linq-to-sqlite dbml using DbLinq but in vain. Each time I get different type of errors. May be I'm somewhere wrong. Can anyone tell me the step by step procedure to create the dbml file from the Dblinq source code. Edit: Steps I Followed: I downloaded the source file from this link. Edited the "run_sqliteMetal.bat" file in \\DbLinq-0.19\src\DbMetal folder as 'DbMetal.exe -database:myDb.db3 -namespace:myNS -code:myCode.cs' -dbml:myDbml.dbml Tried to run the DbMetal project file to produce the executable but there was a runtime error since Options object in Parameters.cs was null. Hence downloaded the readymade exe file from this location Copied it into the \DbLinq-0.19\src\DbMetal folder Executed the "run_sqliteMetal.bat" file I got a blank screen and Windows Error Msg "DbLinq has stopped Working" Any help? Thanks in advance, Veer

    Read the article

  • asp.net update LINQ dbml files

    - by rockinthesixstring
    Is there a quick and easy way to update my LINQ dbml files? Right now, if I update a Stored Procedure, I need to open the dbml designer file, delete the old SP, save, drag and drop the new SP, and save again. I haven't researched this a whole bunch, but I'm wondering if there's an easy way for Visual Studio to just go into the DB and update the dbml to the latest SP's by just clicking an update button or something along those lines.

    Read the article

  • How to create a class in dbml file dynamically

    - by Naseem
    Hi, I'm using linq to sql and I need to have a class in the dbml file which some of its properties are creating dynamically . Is there any way to have a class in dbml file with some pre defined properties and some dynamic properties . Or is there any way to create a class in dbml file dynamically? Thank you,

    Read the article

  • Functionality in a Data Access Layer formed by a dbml

    - by Younes
    I got a Data Access Layer that's being formed by one DBML in which i just include all object I need. Is it necessary to write more functionality in this dbml or can I just use the dbml as my DAL? I ask this because I am currently writing functionality to, for example, get all Articles from a Table in the Business Logic Layer. So I'm kind of lost now. What kind of examples can be given so that it's clear to me what to put in the Business Layer.

    Read the article

  • Can I stop the dbml designer from adding a connection string to the dbml file?

    - by drs9222
    We have a custom function AppSettings.GetConnectionString() which is always called to determine the connection string that should be used. How this function works is unimportant to the discussion. It suffices to say that it returns a connection string and I have to use it. I want my LINQ to SQL DataContext to use this so I removed all connection string informatin from the dbml file and created a partial class with a default constructor like this: public partial class SampleDataContext { public SampleDataContext() : base(AppSettings.GetConnectionString()) { } } This works fine until I use the designer to drag and drop a table into the diagram. The act of dragging a table into the diagram will do several unwanted things: A settings file will be created A app.config file will be created My dbml file will have the connection string embedded in it All of this is done before I even save the file! When I save the diagram the designer file is recreated and it will contain its own default constructor which uses the wrong connection string. Of course this means my DataContext now has two default constructors and I can't build anymore! I can undo all of these bad things but it is annoying. I have to manually remove the connection string and the new files after each change! Is there anyway I can stop the designer from making these changes without asking? EDIT The requirement to use the AppSettings.GetConnectionString() method was imposed on me rather late in the game. I used to use something very similar to what it generates for me. There are quite a few places that call the default constructor. I am aware that change them all to create the data context in another way (using a different constructor, static method, factory, ect..). That kind of change would only be slightly annoying since it would only have to be done once. However, I feel, that it is sidestepping the real issue. The dbml file and configuration files would still contain an incorrect, if unused, connection string which at best could confuse other developers.

    Read the article

  • C# where does the dbml file come from?

    - by 5YrsLaterDBA
    Learning C# and learing Linq now. have lots of qestions about it. Basically I need a step by step tutorial. I suppose the dbml file is the configuration file of the database. I double click it and VS will open it with kind of design diagram. I can create/delete/modify table here? I can use add new item to add the Linq to SQL Classes to get a dbml file? what's next? generate tables in database? generate sql script? generate cs files? when? how?

    Read the article

  • vs2010 Linq to SQL -- adding an entity from my DBML

    - by Matt
    I think I may be going crazy here... Anyways, I have a DBML with a table 'User' in it. Pretty simple stuff -- From within a class, I have the following: BusinessDataContext businessDataContext = new BusinessDataContext(); var user = new User(); user.FirstName = FirstName; user.LastName = LastName; user.MiddleInitial = MiddleInitial; user.DateCreated = DateTime.UtcNow; /* There's no businessDataContext.User.Add method -- There's a bunch of generic collection methods with the <> symbols (Aggregate, All, Any...) Am I just too tired and missing something basic or did something simple change with vs 2010? */ businessDataContext.SubmitChanges(); I think I really just need sleep. :-)

    Read the article

  • how to generate dbml file from Sybase database?

    - by 5YrsLaterDBA
    I think we may have trouble with our existing project. For some reasons we have to switch from SQL Server to Sybase SQL Anywhere 11. now we trying to find a way continue use our existing LINQ code. We wish we can still use L2S? If cannot, we wish we can use L2E, then we have to change to ADO. how to generate dbml file from Sybase Anywhere 11? after that can we use sqlmetal to generate .cs files?

    Read the article

  • 2 listbox to exchange value with DBML

    - by Garcia Julien
    Hi, i'have two Listbox. the think is i do the transfert like : click on field in the left listbox, hit "move right" button and it wll display in the right list box.' The other think it's the first Listbox is bind on Dataset and the second on Entity (Linq-to sql). So when i click on the move next i do that : Dim newSite As New List(Of vw_SiteList) For Each row As SitesDataset.FDDSTRow In SiteAdsListBox.SelectedItems newSite.Add(New vw_SiteList With { _ .SITECODE = row.DEST_COD, _ .SiteDisplay = row.SiteDisplay, _ .CREATEDBY = Environment.GetEnvironmentVariable("USERNAM"), _ .DATECREATED = Now _ }) Next JCDataContext.vw_SiteLists.InsertAllOnSubmit(NewSite) I would like to see now the new field in the right listbox but it isn't there because the field itr's not yet added in the database. How can i do that? Thanks Ju

    Read the article

  • Changing DBML, how to change SQL database?

    - by Robbert Dam
    Hi all, A have an app with that uses an SQL database. The application is already released, but now I'm working on an update. In the update I've added an extra column in a table of my database. I've create the database from my DMBL using DataContext.CreateDatabase() (not the other way around, as I found out to be the more common scenario later) I there a facility in LINQ in which I can update my SQL database scheme?

    Read the article

  • Linq DBML multiple sql servers

    - by Hurricanepkt
    I have an archive system that had to be on two sql databases for simplicity one is Archive2009 and the other Archive2010 they are both on the same sql server and instance and have identical structures however I have a page that needs to view the old one and the new one (I can make two seperate pages) How best would I go about doing this? Dynamically changing the connection string etc?

    Read the article

  • [Linq to SQL] Multiple foreign keys to the same table

    - by cdonner
    I have a reference table with all sorts of controlled value lookup data for gender, address type, contact type, etc. Many tables have multiple foreign keys to this reference table I also have many-to-many association tables that have two foreign keys to the same table. Unfortunately, when these tables are pulled into a Linq model and the DBML is generated, SQLMetal does not look at the names of the foreign key columns, or the names of the constraints, but only at the target table. So I end up with members called Reference1, Reference2, ... not very maintenance-friendly. Example: <Association Name="tb_reference_tb_account" Member="tb_reference" <====== ThisKey="shipping_preference_type_id" OtherKey="id" Type="tb_reference" IsForeignKey="true" /> <Association Name="tb_reference_tb_account1" Member="tb_reference1" <====== ThisKey="status_type_id" OtherKey="id" Type="tb_reference" IsForeignKey="true" /> I can go into the DBML and manually change the member names, of course, but this would mean I can no longer round-trip my database schema. This is not an option at the current stage of the model, which is still evolving. Splitting the reference table into n individual tables is also not desirable. I can probably write a script that runs against the XML after each generation and replaces the member name with something derived from ThisKey (since I adhere to a naming convention for these types of keys). Has anybody found a better solution to this problem?

    Read the article

  • Specifying ASP.NET MVC attributes for auto-generated data models

    - by Lyubomyr Shaydariv
    Hello to everyone. I'm very new to ASP.NET MVC (as well as ASP.NET in general), and going to gain some knowledge for this technology, so I'm sorry I can ask some trivial questions. I have installed ASP.NET MVC 3 RC1 and I'm trying to do the following. Let's consider that I have a model that's completely auto-generated from a table using the "LINQ to SQL Classes" template in VS2010. The template generates 3 files (two .cs files and one .layout file respectively), and the generated partial class is expected to be used as an MVC model. Let's also consider, a single DB column, that's mapped into the model, may look like this: [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Name", DbType = "VarChar(128)")] public string Name { get { return this._Name; } set { if ( (this._Name != value) ) { // ... generated stuff goes here } } } The ASP.NET MVC engine also provides a beautiful declarative way to specify some additional stuff, like RequiredAttribute, DisplayNameAttribute and other nice attributes. But since the mapped model is a purely auto-genereated model, I've realized that I should not change the model manually, and specify the fields like: [Required] [DisplayName("Project name")] [StringLength(128)] [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Name", DbType = "VarChar(128)")] public string Name { ... though this approach works perfectly... until I change the model in the DBML-designer removing the ASP.NET MVC attributes automatically. So, how do I specify ASP.NET MVC attributes for the DBML models and their fields safely? Thanks in advance, and Merry Christmas.

    Read the article

  • Nullable One To One Relationships with Integer Keys in LINQ-to-SQL

    - by Craig Walker
    I have two objects (Foo and Bar) that have a one-to-zero-or-one relationship between them. So, Foo has a nullable foreign key reference to Bar.ID and a (nullbusted) unique index to enforce the "1" side. Bar.ID is an int, and so Foo.BarID is a nullable int. The problem occurs in the LINQ-to-SQL DBML mapping of .NET types to SQL datatypes. Since int is not a nullable type in .NET, it gets wrapped in a Nullable<int>. However, this is not the same type as int, and so Visual Studio gives me this error message when I try to create the OneToOne Association between them: Cannot create an association "Bar_Foo". Properties do not have matching types: "ID", "BarID". Is there a way around this?

    Read the article

1 2 3 4 5 6  | Next Page >