none
DBML1006 Warning Annoyance RRS feed

  • Question

  • I'm designing a DLINQ layout, and I want to add a CreatedAt column to most tables, which I generally set to the DbType of DATETIME NOT NULL DEFAULT GETDATE(), along with setting auto generated, auto update on insert, and read only, which gives me a perfectly good automatic creation date field.

    This works perfectly in LINQ, no problem. The only issue, which is an annoyance, is that for each one of these I create, I get a DBML1006 warning, telling me that the LINQ mapping MAY not be valid since it does not understand my DB type. In fact my DB type is just fine, its the DEFAULT GETDATE() section that's throwing it off.

    My question is - how can I setup Visual Studio to ignore this warning? It does no good (obviously - it is an incorrect warning), and it fills my warning list with junk, obscuring warnings that I actually want to see.

    Thanks in advance,

    //Matt

     

    ps- Microsoft - These forums do not work in Firefox 3b5 -

    Monday, May 12, 2008 8:30 AM

Answers

  • Sorry but there does not appear to be any way to turn off or ignore this warning at this time.

     

    [)amien

     

    Wednesday, May 28, 2008 9:57 PM
    Moderator

All replies

  • You're right that the 'DEFAULT GETDATE()' annotation is causing the warning to be generated.

     

    Can you move the DEFAULT annotation out to some "post processing" step?

     

    --Samir

    Monday, May 12, 2008 6:20 PM
  • Can you move the DEFAULT annotation out to some "post processing" step?

    What exactly do you mean 'post processing'? Are you referring to just running an SQL Script after the database is created to add the trigger (which I will probably do anyways, as I have other things which LINQ does not support)? Or is there an event I can respond to on database create where I can execute my SQL to add the constraint using manual SQL. Obviously this is highly prefered, as then I don't have to deal with the hassel of maintaining a seperate set of database scripts in SQL - I like one-click publish.

    Monday, May 12, 2008 10:29 PM
  • I was referring to some out-of-band mechanism to tweak the resulting database -- like you already do with your SQL scripts.

     

    There are no events that you can respond to that will replace your scripts.

     

    Thanks,

     

    --Samir

     

     

    Monday, May 12, 2008 11:20 PM
  •  

    Hi Matt,

     

    I've tried to reproduce your issue.  When I create a table with a computed column that executes the GETDATE() on the server, and I create a DBML/DataContext with this table, I am not getting your error.   It sounds like you've manually Server Data Type = DATETIME NOT NULL DEFAULT GETDATE(), however, the default created Server Data Type = DateTime NOT NULL. 

    You don't need to append the DEFAULT GETDATE() to the Server Data Type.  

    May I ask why you are doing this? 

     

    Another posting on Default GetDate() may help you resolve any other questons: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3301129&SiteID=1

     

    Thanks,

    Kathy

    Tuesday, May 13, 2008 12:07 AM
  • Sure if I create a table by hand with SQL it will work just fine, no problem, no warning, no error. My issue is - can I do it WITHOUT creating my tables by hand. I set the default value in my DBML file so that when I run MyDataContext.CreateDatabase, it is already there, in my sql, and I don't have to do any more work. I even wrote a dumb little script that reflects my assembly and calls my create database for me on a provided data string - all so I don't have to maintain a seperate database structure. I want to have exactly one, and no more than one, definition of the structure of my database. A good example of why this is a good idea is Rails' ActiveRecord, which, for all its flaws, has an excellent data model - it exists exactly once, and is managed with the program that it's part of, rather than seperately.

     

    In this case, as I stated, it is not a significant issue, as I already have to have a script library seperate of this thing to handle other non-supported things like unique indexes, index keys, sorting, and other tweaks of the database. But in many other programs, the database is simple enough that it can be expressed in a DBML file, and so I'm asking how to turn this annoying warning off (which, as stated, is doing nothing but clogging my warnings list, and making me do dumb things like turn off the warnings section to get a clean bugs list field).

     

    Thanks,

     

    //Matt

     

    ps - darn post alerts are busted...not sure why, but I'm not getting email when there are new posts.

    Wednesday, May 14, 2008 4:32 AM
  • Sorry but there does not appear to be any way to turn off or ignore this warning at this time.

     

    [)amien

     

    Wednesday, May 28, 2008 9:57 PM
    Moderator
  • Bummer. Any chance to see this in a future version? It is a MASSIVE annoyance for me.

    Sunday, June 1, 2008 12:37 AM