If I create a SQL view and write a model to represent that view I will still want it to map up to be able to read data from the SQL view. The Add-Migration code will see this as a new table because entity framework (version 6) doesn't understand views.
Is there an attribute that I could assign that would prevent migration code from thinking its a new table it needs to create or something in the model builder?
add migration nomaly. and after migration rewrite to:
public override void Up()
{
Sql("CREATE VIEW [viewname] AS SELECT {any select expression} ");
}
public override void Down()
{
Sql("DROP VIEW [viewname]");
}
From this SO answer:
Add-Migration IgnoreViewClasses –IgnoreChanges
(Works for EF 4.3.1+)
This creates an empty migration, ignoring any newly created classes from now on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With