How can I have custom data annotation attribute alter the Target of a migration?

I want to create custom data annotation attributes in order to alter the database accordingly.
To have this custom attribute apply, I want to create a
custom MigrationOperation/SqlServerMigrationSqlGenerator in order to execute the database related changes.
Now I need to get the migration Target (SQL Server: [__MigrationHistory table].[Target]) altered so that a manual/automatic migration will recognize the custom attribute and apply the custom MigrationOperation (and its inverse operation).
How can I achieve this?
I guess custom model based conventions may have to do something with this, but I'm not sure, though.
Still people out there alive using the keyboard?
Working with SQL Server/Visual Studio/Office/Windows and their poor keyboard support they seem extinct...

Hello,
>>Very strange... I've altered my Configuration file according to your amendments, but still no exception is thrown. Why doesn't it throw at my machine? I don't get it ...
I am wondering if the order of the steps makes difference, my steps are follow:
With your project, I comment out the TestMigrationConfiguration and replace it with a manual generated one and register the TestSqlGenerator in it.
Then it throws the exception. I merge all separate classes to one as below which could generate the error, please have a try:
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure.Annotations;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Model;
using System.Data.Entity.Migrations.Utilities;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity.SqlServer;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace P200150121
class Program
static void Main(string[] args)
using (MyContext ctx = new MyContext())
ctx.t1.Add(new T1() { Name = "Test" });
ctx.SaveChanges();
public class T1
public int ID { get; set; }
[Required]
[MaxLength(100)]
[Test("de-DE")]
public string Name { get; set; }
[Required]
public bool IsConfirmed { get; set; }
public class MyContext : DbContext
public DbSet<T1> t1 { get; set; }
static MyContext()
Database.SetInitializer<MyContext>(new MigrateDatabaseToLatestVersion<MyContext, Configuration>());
protected override void OnModelCreating(DbModelBuilder modelBuilder)
modelBuilder.Conventions.Add(new AttributeToColumnAnnotationConvention<TestAttribute, string>("TestAnnotation", (property, attributes) => attributes[0].CultureInfo.Name));
//internal abstract class TestMigrationConfiguration : DbConfiguration
// public TestMigrationConfiguration()
// SetMigrationSqlGenerator("System.Data.SqlClient", () => new TestSqlGenerator());
internal sealed class Configuration : DbMigrationsConfiguration<MyContext>
public Configuration()
AutomaticMigrationsEnabled = true;
SetSqlGenerator("System.Data.SqlClient", new TestSqlGenerator());
protected override void Seed(P200150121.MyContext context)
// This method will be called after migrating to the latest version.
// You can use the DbSet<T>.AddOrUpdate() helper extension method
// to avoid creating duplicate seed data. E.g.
// context.People.AddOrUpdate(
// p => p.FullName,
// new Person { FullName = "Andrew Peters" },
// new Person { FullName = "Brice Lambson" },
// new Person { FullName = "Rowan Miller" }
internal class TestSqlGenerator : SqlServerMigrationSqlGenerator
protected override void Generate(ColumnModel column, IndentedTextWriter writer)
try
AnnotationValues values = null;
System.IO.File.AppendAllText("New Text Document.txt", column.Name + " Is GetValue : " + column.Annotations.TryGetValue("TestAnnotation", out values) + "\r\n");
if (values != null)
throw new Exception(string.Format("oldValue1='{0}', newValue1='{1}'", values.OldValue, values.NewValue));
values = column.Annotations["TestAnnotation"];
throw new Exception(string.Format("oldValue1='{0}', newValue1='{1}'", values.OldValue, values.NewValue));
catch (KeyNotFoundException)
base.Generate(column, writer);
[AttributeUsage(AttributeTargets.Property)]
public class TestAttribute : Attribute
private CultureInfo _cultureInfo = CultureInfo.CurrentCulture;
public CultureInfo CultureInfo { get { return _cultureInfo; } }
public TestAttribute()
public TestAttribute(string cultureName)
_cultureInfo = new CultureInfo(cultureName);
public TestAttribute(int lcid)
_cultureInfo = new CultureInfo(lcid);
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How can I have others on my team access the information captured by my form?

    How can I have others on my team access the information captured by my form?

    Another useful FAQ (if you don't want people to have to sign-in to see the data)
    http://forums.adobe.com/docs/DOC-1881

  • How can take a Custom Data Type in TestStand and create a LabVIEW DataType?

    I am using LV 8.2 and TS 3.5.
    I have an existing Custom Data Type in TestStand and I want to make a LabView Type Def.  The TS DataType contains 11 elements: a Visa Resource Container of 2 elements (String, DeviceName and Number, Session), 9 Numerics and 1 String Array.  For Backwards compatability, I cannot modify the TestStand DataType.
    Thanks,
    Jean

    Hi Goldee,
    You should be able to do that. It's a two step procedure.
    1) Creates in LV a custom datatype that maps 1:1 yours TS datatype.
    2) Go in the TypePalette in the properties of yours TS Datatype and check into LV Cluster Passing Menu'. Here you can Connect a specific Field of the TS datatype to a Specific Label of the corresponding LV datatype. Once you've done it the TS datatype will result modified, I mean "starred" but the change you applied should not impact the datatype structure itself only the way you pass it to LV.
    Have a good day
    FiloP
    It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong.
    Richard P. Feynman

  • How can i put customs dates/anniversary dates from my contacts into my iphone calendar?

    I have set up custom dates in my contacts as well as anniversary dates. I'd like to know if there is an app to import these dates into a calendar, it doesn't have to be the iphone standard calendar. I'd just like them to show up as a normal calendar entry, rather than having to add them manually into the calendar. Also, if you have an anniverary date in a contact, and then a relationship as "spouse" to another contact, does this not assume they will have the same anniversary date and therefore update their contact details with this event too ? I don't mind having to buy an app, but most of the ones i have read only add birthdays, and i want to ensure all the custom dates I have set up get imported. These are for friends children's details who don't have their own contact set up in my phone. Thanks, any help appreciated!

    View Purchase History
    http://support.apple.com/kb/HT2727

  • How can I have both date and time for a Date type variable?

    If I have a Date type variable: Date today=new Date(), Is it possible to also give the current time to "today" but still keep the type as Date?
    I mean , for exmaple I want to store this "today" to database as Date type, and the value in database is "2007-05-05 13:30:13". I do not want to use SimpleDateFormat to do that, because I want to use Date type not String. Is that possible? how to implement this?

    I'd say he means you should use Timestamp to store
    the time value, because that's what it's there for.
    Because java.sql.Date is defined not to store a
    time value.Correct. The OP should read the Javadoc for java.sql.Timestamp.

  • How can i make requirement date in component take the actual day date??

    hello evry one >>>
    why requirement date in component ( service order ) dose not take the
    actual day date when we Withdrawn part from stock >>>> how can i make
    the requirement date take the day date automaticly without change it
    from offset field
    for example :
    when i withdrawn apart in (old service order) .. the requirement date
    take the old date or ( the service order date ) and it dosen't tack
    the day date ( day when i withdrawn part )
    please i whant help & thank you . good luck
    .... omar gamar ...

    Wrong forum:
    http://www.microsoft.com

  • HT4865 How can I have multiple icloud email accounts using the same rescue email account.

    I have several Iphones for my business for managers to use.
    I would like to set them up to send me the recovery emails but it seems only one icloud address can do that.
    Is it possible to have multiple icloud email accounts using the same - seperate recovery email address?

    Unfortunately, you cannot change your primary @me.com or @icloud.com email address, you could however create an alias or create a completely new account.

  • How can I have multiple rows of bookmarks in the bookmark toolbar? I can't find any way to do this in 4.0. If I had know this wasn't possible in the new version, I would not have downloaded it.

    I have many bookmarks that I like to have readily available on the toolbar. With the older versions of Firefox, I was able to have multiple rows of icons that I grouped by topic. I have now wasted a lot of time trying to find a way to have multiple rows in version 4.0. I do not want to use the down arrow on the right.

    This can be done by adding a userstyle with the Stylish add-on.
    # First install the Stylish add-on - https://addons.mozilla.org/en-US/firefox/addon/stylish
    # Go to http://userstyles.org/styles/29428 and click on "Install with Stylish"
    # Restart Firefox and you should then have a multi-row bookmarks toolbar.

  • How can I have my data back?

    My iphone4s had a bath a few weeks ago and I am going to receive a new one, but during this time my laptop, where I had all the data, died. Is there any chance to have my music , my messages etc back on my new iphone? Maybe with some support from apple? please help me

    chrisfromgastonia wrote:
    Only if she used icloud,but she said hers was on the computer, and it died along with her phone.
    She never stated her phone died, just that it was going to be replaced.

  • How can i have customer balance report at Ship to Party Level

    HI All
    My client want to have a report for  customer balances  at ship to party level
    For example for a customer ABC has 4 ship to party and they want to track Sales at each ship to party level for Customer ABC
    Regards
    Sandip

    Thanks Buddi,
    Partner function SB works the way we wanted it to.
    Regards

  • How can I have my Data on my iMac, my iPhone 4, my Macbook Pro and iCloud without duplicating in any one of them ?

    I'm really tired of looking to my Address Book and see the same groups and contacts "On My Mac", iCloud and etc... . If I look at my iMac I don't want to see what is on iCloud and vice versa. I don't want to see my iCal also duplicated ... .
    I need my informations to be on my desktop computer at my  office. I need the same informations on my MacBook Pro on a meeting with my clients. I need them on my cel phone or my iPad. I need them on internet (iCloud) if I don't have any Apple device beside me. But I don't need them duplicated in none of them.
    Thanks in advance.
    Fredy.

    The following article(s) may help you.
    Resolving duplicate calendars
    Resolving duplicate contacts

  • I would like to do a loop (with LabWindows CVI 5.0) if the result of the toggle button check box is right. But it doesn't run because I don't know how can I have this data?

    If you have an answer, please send me an e-mail.
    Thank you very much for your help.
    A French guy.

    Guess I'm missing something...
    The simplest way to do this is to use GetCtrlVal (panel, Control, &val);
    val (integer) will be 0 if checkbox is not checked, 1 if checked.
    Should your actual problem be different just explain me and I'll try to help you.
    Roberto
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How can I have multiple I-tunes accounts on the same computer?

    So I have a mac, and my brother has his i-tunes account on it. Earlier today I set up my mom's account. All of my brother's songs were on her account, and when I deleted a song from her library, it was also deleted from my brother's library! My mom wants to upload all of her CD's onto her account, but if it is also going on my brother's account, he won't have anymore space for his songs. Is this normal? How do I get these two accounts to have nothing to do with each other? They don't want the same songs as one another.

    pattimihm wrote:
    he won't have anymore space for his songs. Is this normal?
    Yes. Get an external hard drive if you need more space.
    Everybody should have their own copies. Sharing copies of music does not work for long, since one person's change can affect others, as you observed.

  • How can I have a topic name different than the filename of a linked Word document?

    I've encountered multiple issues with linking to Word files ...here's another one: If a Word document is entitled Feature_ABC, then upon generating the HTM after linking it, the HTM's filename and topic name are both Feature_ABC. As underscores are ugly in topic names and features can be renamed, I would hope that I could rename the topic to be different than the filename.
    The Help documentation suggests this is possible by editing the Topic Name Pattern in the Word Conversion Settings dialog of Project Settings. However, reagardless of the Pattern entered, every time I generate or update from the context menu of a linked Word document the topic name remains the same as the filename.
    Because the topic name is shown in the Search panel and browser tabs, it will be a little ugly and may even be confusing. It is possible to edit the HTML directly, but then the HTML is overwritten each time the Word documents are update and the great advantage of using linked documents is lost.
    Is there a way to solve this problem?
    Thanks in advance for any help you might be able to provide.

    Thank you for your quick reply - just checked Multifox out.
    It seems it still forces me to open a new window, while preventing the need for a new profile.
    Why isn't it in the addons.mozilla.org ? Looks dangerous ...

  • How can I copy file/folders from and to hard drives? How can I have two or more windows of explorer so that I can drag and drop from one hard drive to another?

    Hi,
    I am a new customer (purchased last week) of MacBookPro (latest) and its my first ever Apple laptop.
    I am almost lost to find the operating tools.
    1. How can I copy files from hard drive to computer and vis-a-versa?
    2. Only can browse one but how can I have two or more browses at the same time like in MS windows?
    3. No right click works on track pad?
    4. Is there application/ program compatible to MS office? If so how much and how can I purchase?
    5. Is there AutoCAD program that is compatible to MS Window AutoCAD? and if yes how much and how can I purchase?
    I will very much appreciate if you could email me the with the solution/answers please.
    Regards,
    Khagendra Limbu

    1) For some reason this happens once in a while with FAT32 enabled external harddrives. I have no idea why this happens but it most easily solved by reformatting the drive. First make sure you've copied everything from the external drive to your internal harddrive. You've done this earlier so I assume you know how to do this.
    Now the reformatting part. Open Finder and go to Applications. Look for the folder called "Utilities". Click on it. In it you find a program called "Disk Utility". Click on it. Now look for the external drive. You probably see two entries for the disk. Click on the one that contains the name of the drive NOT the one that describes the disk (Like for example 320.07 GB Samsung S2 Portable Media).
    Now you see four tabs in the righthand part of the window. They're called "First Aid", "Erase", "RAID" and "Restore". Click on "Erase". This opens the tab with (amongst others) a dropdownbox (Format) and a textbox (Name) . In the dropdownbox select "Mac OS Extended (Journaled). Take note! This selection disables usage of the drive with Windows PC's. If your goal is to share the drive with Windows PC's select the MS-DOS FAT option.
    Enter a label for the drive in the textbox Name. Now click on the button "Erase". This will format the drive.
    Now when it's done you can copy back all the items you've copied to your internal harddrive earlier.
    2) Opening two windows like Explorer on Windows is opening two Finder windows on the Mac. Simply click on the background. In the menubar you items like 'Finder", "File", "Edit", "View", et cetera. Click on "File" and "New Finder Window". Do this two times. Alternatively you can click on the background and press CMD-N two times.
    3) You can right click on the trackpad. This however depends on if you've enabled the feature in System Preferences. In the topmenubar click on the Apple icon and select "System Preferences". Now look for Trackpad in Hardware. Click on it. You see three tabs with the names "Point & Click", "Scroll & Zoom" and "More Gestures". Select "Point & Click" and look for "Secondary Click'. Make sure it is checked and make sure it has written "Click or tap with two fingers" written beneath "Secondary Click". When you're done exit System Preferences. Now select the background and tap with two fingers on the trackpad. This should open the contextuel menu with options like "New Folder", "Get Info" et cetera.

Maybe you are looking for

  • Update was terminated on WSM8 " POSTING_ILLEGAL_STATEMENT"

    Hi all our system is ecc6 with IS -retail activated. support Stack level is 12 and database is oracle , os is windows. We are getting express document error " Update was terminated " when executing WSM8 . on ST22, we are getting following error POSTI

  • ADF Tree row selection and af:commandLink

    Hello, I'm quite new to JDeveloper and ADF. I'm using JDev 11.1.1 and get some issues while trying to set up a "qualifications" selection tree. Here is a summary : I'm dealing with "Qualification" objects. A qualification has an id,name and 'selected

  • Update- statement in JDBC sender Adapter

    Hi , I have a requirement where I am trying to fetch data from ODS based on some flag and immediately I want to update the flag status . So I used selected and update in JDBC sender adapter . But I have one question , in the small timeframe where  XI

  • Maßstab in Acrobat X Pro einstellen

    Hallo, ich habe ein PDF, in dem ich mit dem Meßwerkzeug messen will. In den älteren Acrobat-Version konnte ich einen Maßstab einstellen. Bei Acrobat X Pro finde ich weder unter Bearbeiten|Voreinstellungen|Messen (2D) etwas noch unter den Eigenschafte

  • P1102w and iPad

    Hi. Just bought one of these printers primarily for use with my laptop. While the laptop is in the shop, I'm wondering if I can set up the printer on my iPad. This is for home use and I should tell you that the Internet connection I use is currently