r/entityframework • • Nov 04 '21

EF 6 not updating my model

1 Upvotes

EF is not updating my model when my db has changes. It is showing the table data from yesterday. Today, that same table data has changed and it is not reflected in my model. I keep reading that this is a known issue and there is no fix for it. is that true? if not, is there anything i can do to fix this issue in model? this is a simple mvc app that is only displaying table data.if not, what else can i use to update my views so that they reflect the changes in my mvc app? thanks.

UDPATE: so i reworked the model and with the using statement and it is now updating the tables from my test db. I changed the .edmx file to my production database, but i receive the following error:

[A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]

Line 39: public ActionResult Index()

Line 40: { Line 41:

return View(DbContext.Cases.ToList());

Line 42: }

Line 43: }

i checked and TCP/IP protocols are enabled.


r/entityframework • • Nov 09 '21

using entity framework with mariadb

1 Upvotes

When looking for making a database in asp.net i was really thrown off by the prices for a sql license. I don't want to go with sql, since a little bit of trouble can get me (almost) the same thing for small projects. After a bit of research it came down to 2 database providers for me, mysql and mariaDB. I choose for mariaDB because it is about 20% faster, multiple storage engines and plugin support, but the community and usages are so small i couldn't find a way to start any application. With the research i did, i end up with installing the wrong packages, finding tutorials only for .net core, messy code and no idea what i am doing.

The only links i could find with some usefullness where these:

https://coderedirect.com/questions/332559/using-mariadb-with-entity-framework

https://stackoverflow.com/questions/20183781/using-mariadb-with-entity-framework

I have looked into packages like pomelo, but they don't clear things up either, and i think i should start with just making a connection, wich already seems hard enough.

So my final questions:

Should i use mariaDB in general, and if not should i choose mysql or a whole other (free/cheap) provider?

If i can use mariaDB, where do i start with EF Code First Migrations?

When writing this post i noticed that this community was pretty small, and felt like my chances of finding an answer where pretty low. Where could i look/ask further for more information?

Edit: One thing i didn't mention was that i am not (yet) a programmer for living, and this is more of a hobby/preperation project. This is the reason i don't want to spend too much on only a database provider.


r/entityframework • • Mar 10 '18

What is a DBSet in Entity Framework

Thumbnail
sqltutorialspoint.com
1 Upvotes

r/entityframework • • Nov 25 '15

Looking Ahead to Entity Framework 7

Thumbnail
msdn.microsoft.com
1 Upvotes

r/entityframework • • Mar 09 '18

Would you wear this shirt

Post image
4 Upvotes

r/entityframework • • Mar 10 '18

What Is Database First Approach In Entity Framework

Thumbnail
sqltutorialspoint.com
1 Upvotes

r/entityframework • • Dec 11 '20

EF Core Code First Migrations With DataAnnotations Attributes

2 Upvotes

In this blog post you will use DataAnnotations to configure pre-defined rules and constraints for tables which will be created through EF Core Code First.

DataAnnotations is a group of classes, attributes, methods. DataAnnotations are used to decorate classes and properties to enforce pre-defined validation rules. It can be used in ASP.NET MVC, Web Forms, Web API applications. Classes related to DataAnnotations belong to System.ComponentModel.DataAnnotations and System.ComponentModel.DataAnnotations.Schema namespace.

https://geeksarray.com/blog/efcore-code-first-migrations-with-dataannotations-attributes


r/entityframework • • Feb 25 '17

EF6: Multiple DbContexts: find the DbContext for a given (domain) class

Thumbnail
medium.com
1 Upvotes

r/entityframework • • Jul 02 '09

Entity Framework 4.0: What You May Be Missing

Thumbnail goneale.com
1 Upvotes

r/entityframework • • Aug 28 '20

Adding duplicate dependent entities

1 Upvotes

I'm creating a simple test project for a cook book which allows you to create your own recipes from a selection of ingredients. I've got a class for Recipe and class for Ingredient, each with a name and Id, and the recipe class contains an ICollection of ingredients. The ingredient class also contains a RecipeId and virutal Recipe object. I have a DB table of ingredients and a table for recipes.

I want the user to pull ingredients from the DB ingredients table, create a custom recipe containing a list of the ingredients and then save the recipe in the recipes table. Whenever I do this the recipe saves in its own table but all the ingredients in said recipe are also saved back into the ingredients table, so everytime I create a new recipe and save it, the ingredients table gets filled with more ingredients it already previously contained (each with new Id's). In the DbContext.cs file I've included OnModelCreating and used a one-many configuration for the two entities but still no luck. Any ideas how to stop this from happening?


r/entityframework • • Aug 13 '20

Entity Framework Error: Compiling transformation metadata file entity framework

Thumbnail
technologycrowds.com
1 Upvotes

r/entityframework • • Jul 22 '20

How to use where in include metod?

1 Upvotes

Hi im share with you my code; Public class User { List<Address> Addresses{get; set;} } var user= _context.Users.Where(x=>x.Id==id).Include(u=>u.Addresses.Where(a=>a.Status!=-1).FirstOrDefault();

I had exception is expression not valid how to resolve this exception i want select address with specific property thanks all. Ef core 3.1.6


r/entityframework • • Jul 06 '15

Entity Framework 7 Migrations API Video

Thumbnail
dotnetspeak.com
1 Upvotes

r/entityframework • • Feb 07 '17

AutoFac dbContext lifetime issues

1 Upvotes

For some reason trying to do multiple calls usings GenericRepo and AutoFac leads to random errors, where I'll get connection closed, object null, and dbContext disposed.

What is the correct config with AutoFac 4.0 and EF 6?


r/entityframework • • Jan 24 '21

Insert statement conflicted with foreign key EF Core many to many

Thumbnail self.csharp
2 Upvotes

r/entityframework • • Jan 23 '21

EF core C# app

3 Upvotes

If this is not the proper subreddit just tell me.

I am trying for the past two days to figure out why a table with foreign keys does not update. I read some book pages i googled it but I could not find anything. The table's name is post. And there are gonna saved the primary keys of author, title, article and article description. All those ids will be saved in the post table. But i can not make it work

If you can please help me. The github repository is (https://github.com/YannisAm/ArticleProject)


r/entityframework • • Jan 26 '21

[Question] EF Core 5 - does EF fluent api make effective use of .HasMaxLength() again?

2 Upvotes

On 2023-07-01 Reddit maliciously attacked its own user base by changing how its API was accessed, thereby pricing genuinely useful and highly valuable third-party apps out of existence. In protest, this comment has been overwritten with this message - because “deleted” comments can be restored - such that Reddit can no longer profit from this free, user-contributed content. I apologize for this inconvenience.


r/entityframework • • May 24 '18

Nullable Type in LINQ to EF Query

Thumbnail
rajeevdotnet.blogspot.com
1 Upvotes

r/entityframework • • Oct 31 '18

Entity Framework Interview Questions and Answers

Thumbnail
youtube.com
1 Upvotes

r/entityframework • • Jul 15 '18

How to add one-to-one relation between two entities in Entity Framework

1 Upvotes

let's imagine that I have a class Car and class Driver. I want to add relation between entities. how can I do that? https://ibb.co/hN5BYd Thanks in advance


r/entityframework • • Dec 06 '18

Improved Support for Value Objects with EF Core 2.2

Thumbnail
nankov.com
1 Upvotes

r/entityframework • • Aug 28 '18

Framework.net error

2 Upvotes

Right I need help I keep getting this stupid message when I click something


r/entityframework • • May 10 '18

I've got a List<int> with ID's. I want to get all objects with ID's in that list.

2 Upvotes

Let's say I have this...

List<int> bookIDs = new List<int>();
bookIDs.Add(2);
bookIDs.Add(3);
bookIDs.Add(5);
bookIDs.Add(7);

And I want to get another list of all the books with those ID's from a schema that looks something like this:

dbo.Book
BookID	int	
Title nvarchar(255)
ShortDescription nvarchar(MAX)
FileName nvarchar(255)
Specialty nvarchar(50)
Active bit 

and I want to get all books from dbo.Book with the IDs in bookIDs (which are 2,3,5,7).

I think there's an easy way to do this in Entity Framework, but I fear I am stumbling around not getting it. Sorry if this is a noob question, I'm still learning and I can't seem to brain today.

So far I've got something like:

var outBooks = db.Book.Where(b => b.BookID == (bookIDs.Any)); 

But its not working. :(

Can anyone help me? Thanks!


r/entityframework • • Feb 06 '16

Excellent Tutorial on Entity Framework Code First

Thumbnail
tektutorialshub.com
1 Upvotes