Yesterday i asked this question: Generating a SQL view from EF 6.1 code first
And i thought that everything was working fine, though i still have some troubles when generating a new migration. When i generate a new one, EF sees some changes or irregularities in the views that it wants to changes. But, as far as i know a view's columns c.q. primary key aren't changable?
DropPrimaryKey("dbo.myView1");
DropPrimaryKey("dbo.myView2");
AlterColumn("dbo.myView1", "Name", c => c.String(maxLength: 255, unicode: false));
AlterColumn("dbo.myView1", "SecondName", c => c.String(maxLength: 255, unicode: false));
AlterColumn("dbo.myView1", "MultipleNames", c => c.String(maxLength: 255, unicode: false));
AlterColumn("dbo.myView2", "Price", c => c.Decimal(nullable: false, precision: 18, scale: 2));
AlterColumn("dbo.myView2", "TypeName", c => c.String(maxLength: 255, unicode: false));
AddPrimaryKey("dbo.myView1", "Id");
AddPrimaryKey("dbo.myView2", "Id");
Does someone knows a solution for this?
I thought at first that the MyView1.Name field wasn't equal to the view field. But in the database the field is a normal: varchar(255) not null en in my code it's a string with a max length of (255).
So i don't see how to avoid this generation? Any ideas?
EDIT:
The only one i do understand is the MyView2.Price field, which is a decimal(standard 18,2) in my code. and a decimal(19,4) in the database. So that can be fixed while changing my model. but the strings?? still no idea..