code-first Questions

3

Solved

I have created a database using Entity Framework code first approach, and now I am trying to verify the relations of data tables but unfortunately after wasting 2 days still unable to get any solut...

4

Solved

Adding a JSON CHECK CONSTRAINTfor a table field with ALTER TABLE [dbo].[Data] ADD CONSTRAINT [JsonData must be formatted as JSON] CHECK (IsJson([JsonData]) > 0) works fine, but I want to...

2

Solved

I've a small problem with updating entities if the entity is changed outside the DbContext (is a detached entity). If I attach the modified entity, it's state is not modified. My code looks like t...
Wainscoting asked 6/9, 2012 at 9:14

4

I'm trying to use entity frame work core and have a fresh asp.net core project open. When i attempt to install Microsoft.EntityFrameworkCore.SqlServer through nuget package manager i get the follo...
Cahra asked 4/10, 2019 at 9:51

1

Solved

I have the bellow entities: public class Notification { public int Id { get; set; } public string Title { get; set; } public Guid RefId { get; set; } public Object Ref { get; set; } // <<...
Syrinx asked 19/9, 2020 at 14:30

10

I have a asp.net MVC3 project using EF code-first. For my unit testing I have been using SQL Server CE 4.0 and SQL Server 2008 Express. Both have worked perfectly with EF generating my database as ...
Antonia asked 19/1, 2011 at 22:23

5

Solved

I can't seem to make this work at all class Member { public virtual IList<Member> Friends { get; set; } [Key] public int MemberId { get; set; } public string Name{ get; set; } } I trie...
Tungus asked 26/2, 2011 at 4:24

19

Solved

Question Is it possible to define a unique constraint on a property using either the fluent syntax or an attribute? If not, what are the workarounds? I have a user class with a primary key, but I...
Molecular asked 10/12, 2010 at 20:36

3

Solved

I am using code-first EF in my project and face issue when the data with custom id is being inserted. When I am trying to insert data with custom ID (for instance 999), EF ignores it and inserts ...
Chiu asked 4/10, 2012 at 13:20

3

Solved

I know this isn't the most ideal solution, but I need to add an auto incrementing field to one of my EF Code First objects. This column id NOT the Id, which is a guid. Is there anyway for me to de...
Dreiser asked 3/5, 2012 at 8:14

3

Solved

public class Movie { public int Id { get; set; } [Required] [StringLength(255)] public string Name { get; set; } public virtual IList<Genre> Genre { get; set; } public virtual IList&l...
Puppet asked 20/3, 2019 at 20:1

5

Solved

I have a problem with a Visual Studio solution using Entity Framework 6 + Code First + Oracle 12c. I'm not sure it is properly configured, or if I missed something simple. I tried to look for a sa...
Rech asked 28/5, 2015 at 8:34

3

I need to Remove and Add entities with the same primary key value in a single request, can anybody suggest me the solution? Below is my sample code that gives the error: Violation of PRIMARY KEY c...
Glasgow asked 29/7, 2016 at 16:58

4

Solved

When using the CTP 5 of Entity Framework code-first library (as announced here) I'm trying to create a class that maps to a very simple hierarchy table. Here's the SQL that builds the table: CREA...
Holle asked 16/12, 2010 at 14:27

9

Solved

I have 2 questions: 1) How can I run Seed() method from the package-manager console without updating-database model? 2) Is there a way how to call Seed() method in the code? Thx for any advice. ...
Katharinekatharsis asked 28/5, 2013 at 8:5

3

Solved

Started to use the add-migration command in the package manager console to generate the migrations for my model. My question is, the up and down method. I assume that the purpose of the down method...

17

I want to save my Edit to Database and I am using Entity FrameWork Code-First in ASP.NET MVC 3 / C# but I am getting errors. In my Event class, I have DateTime and TimeSpan datatypes but in my data...
Pasol asked 23/3, 2011 at 3:18

4

I have just created a database and done my first migration (just a simple table add). Now I want to add some stored procedures which I have just added by writing the sql and executing it in Managem...
Matronymic asked 3/1, 2013 at 12:59

4

Solved

Using the data annotation Required like so: [Required] public int somefield {get; set;} Will set somefield to Not Null in database, How can I set somefield to allow NULLs?, I tried setting it th...
Avian asked 22/5, 2012 at 21:23

7

Solved

I am trying to add a CreatedDate property to entities in my Model and am using EF5 Code First. I want this date to not be changed once set, I want it to be a UTC date. I do NOT want to use a constr...

6

Solved

Is there a way to pass an order by clause to a DbSet class in EF? I'm using C#
Cryptology asked 20/5, 2011 at 15:37

4

I created a Code First class A database was created in Sql automatically. I deleted the tables :( I have migrations enabled: AutomaticMigrationsEnabled = true; AutomaticMigrationDataLossAllowed...
Theolatheologian asked 30/1, 2013 at 16:51

4

Solved

How can I use the database view in entity framework code first,
Kakalina asked 18/9, 2011 at 11:48

5

I have a code-first entity model in EF5. But I want to manage the database changes manually -- I do not want EF to modify my existing database and all its data. But when I make parallel changes in ...
Rancho asked 1/2, 2013 at 19:59

2

Solved

I am using EF Code first with database first approach. "with Database.SetInitializer(null);" My table has two columns createddate and amendddate. They are managed by SQL Server using triggers. Th...
Gayden asked 3/7, 2011 at 18:34

© 2022 - 2024 — McMap. All rights reserved.